Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manifest generation #158

Open
kf4x opened this issue Apr 9, 2015 · 12 comments
Open

Manifest generation #158

kf4x opened this issue Apr 9, 2015 · 12 comments
Milestone

Comments

@kf4x
Copy link

kf4x commented Apr 9, 2015

I am not sure what is happening I don't know if this is gradle, transfuse, or what.
I put a project up that reproduces my problem here.

as far I can tell when i build the app i.e. gradle clean build, it successfully builds but I can not run the app there is no option to either.

I look at app/build/intermediates/manifests/full/debug/manifest-debug.xml and contains 2 application tags

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<manifest package="com.javier.test.app" android:versionCode="1" android:versionName="1.0" t:tag="+" xmlns:t="http://androidtransfuse.org" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="21"/>
    <application/>
    <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name=".MainApplicationApplication" t:tag="+,ab,i,l,n">
        <activity android:label="@string/app_name" android:name=".MainActivityActivity" t:tag="+,l,n">
            <intent-filter t:tag="+">
                <action android:name="android.intent.action.MAIN" t:tag="+,n"/>
                <category android:name="android.intent.category.LAUNCHER" t:tag="+,n"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

anyway I got curious and pull apart the apk generated by the grade build, and the only application tag in found is the empty one. I am at a loss of what I have done.

@johncarl81
Copy link
Owner

Shoot. I'm wondering if Transfuse is adding two applications. I'll investigate the code angle, but in the mean time can you update your manifest to include the application like so:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<manifest package="com.javier.test.app" android:versionCode="1" android:versionName="1.0" t:tag="+" xmlns:t="http://androidtransfuse.org" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="21"/>
    <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name=".MainApplicationApplication" t:tag="+,ab,i,l,n">
        <activity android:label="@string/app_name" android:name=".MainActivityActivity" t:tag="+,l,n">
            <intent-filter t:tag="+">
                <action android:name="android.intent.action.MAIN" t:tag="+,n"/>
                <category android:name="android.intent.category.LAUNCHER" t:tag="+,n"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

@kf4x
Copy link
Author

kf4x commented Apr 13, 2015

I spent a little more time digging around. I can't find any problems with transfuse. Transfuse is generating the manifest correctly but android-apt is not configured correctly.

If I do as you say the app builds and runs normally.

Thanks John for looking at this!

@johncarl81
Copy link
Owner

That's good news @JavierChavez. Can you try building with transfuse under the provided scope instead of android-apt, and does it do the same thing to an empty Manifest?

@kf4x
Copy link
Author

kf4x commented Apr 13, 2015

I just tried provided scope and that brought issues with merging manifests and the new android plugin... so in short I could not get that to properly compile

I am going to use this advice until I can figure out manifest variants because I can't figure out what is going on in there.

@kf4x kf4x closed this as completed Apr 13, 2015
@kf4x
Copy link
Author

kf4x commented Apr 30, 2016

So unfortunately this is still an issue.

It has to do with the new Manifest Merger. The Merger gets a hold of it first then adds a tag. I have had success forcing transfuse to fill it in first but its not a very nice solution.

I created a test similar to this with the empty tag. The Manifest object had 2 Applications and sure enough transfuse is treated it as a unique tag and not merging.

I couldn't immediately see any way to either user the marshaller or somewhere in the Manifest model treat an empty tag as mergeable or to not write it when serializing.

Also I did read here that <application> can only appear once 👎. But that might a good way to simplify it.

@kf4x kf4x reopened this Apr 30, 2016
@johncarl81
Copy link
Owner

Trying to run your example app mentioned above I'm getting the following error during the build:

...
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
 Position 1 : Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
 Position 1 : Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

:app:processDebugResources FAILED

FAILURE: Build failed with an exception.

If you're having trouble, there is always the option to turn off manifest management or log out the manifest for manual handing:

apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        transfuseManifestProcessing "off" // "log"
    }
}

To the issue.. what should Transfuse be doing here? I wonder if we could use the Manifest Merger to our advantage, having it merge the Transfuse specific components into the final AndroidManifest.xml.

@kf4x
Copy link
Author

kf4x commented Apr 30, 2016

@johncarl81 I actually didn't think about turning it off. I guess I would have to generate the manifest, merge the one generated by transfuse and google by hand. Then turn it off, and manage it form there.

I tried to add a few cases on the manifest-merge branch

@johncarl81
Copy link
Owner

Hmm, your branch works for me ootb:
screenshot_2016-04-30-23-29-31

@kf4x
Copy link
Author

kf4x commented May 1, 2016

Yeah I left the manifest put together. I need to write some more comments. I realized after i sent it I needed to be a little more clear with the repro.

@kf4x
Copy link
Author

kf4x commented May 1, 2016

Ok I split it up into branches for brevity

  • This is the one that updates the main Manifest but two applications Error 1
  • Empty application tag and doesn't update project manifest only intermediates. This is set up similar to your gradle-transfuse example except with newer gradle, android, & apt versions Error 2

@johncarl81
Copy link
Owner

These are great failure cases. Would you like to offer a fix? Is there anything I can provide to help you along?

@kf4x
Copy link
Author

kf4x commented May 1, 2016

Yes I'll spend some time to do a little more investigation to offer some potential approaches for critique. I like you're idea of using the manifest merge to our advantage.

@johncarl81 johncarl81 added this to the 0.3.0 Release milestone Aug 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants