I need to set the Android attribute
android:usesCleartextTraffic="true"
in an Eclipse Android project, but when I do so, it gives me the error:
No resource identifier found for attribute 'usesCleartextTraffic' in package 'android'
Any ideas on how to fix this problem?
Thanks.
I believe I found the problem. I needed to target a more recent SDK. Unfortunately doing so create a whole host of other problems which I will have to sort through, but they are unrelated to this question.
I am running into a build issue where gradle complains about "getMergedManifest failed manifest merger failed"
the error in the log shows lines like:
WARN - .tools.idea.model.ManifestInfo - getMergedManifest failed Manifest merger failed : Attribute provider#com.google.firebase.provider.FirebaseInitProvider#authorities value=(com.xxxxxxxxxx.feature_team.firebaseinitprovider) from AndroidManifest.xml:10:13-72
is also present at AndroidManifest.xml:36:559-633 value=(com.xxxxxxxxx.base.firebaseinitprovider).
Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml:8:9-12:39 to override.
What am i suppose to do here?
I don't have any authorities section in any of my manifest files.
The error arrives when in 2 feature modules the same shared library is imported which in result is depending on some google libs. I am sure that all versions of external libs are the same.
Anyone knows how to solve this?
------- edit. Still got errors ------.
......./base/src/main/AndroidManifest.xml:70:13-46 Error:
Attribute activity#com.facebook.LoginActivity#splitName value=(feature_match) from [:feature_match] AndroidManifest.xml:70:13-46
is also present at [:feature_topvoters] AndroidManifest.xml:73:13-50 value=(feature_topvoters).
Suggestion: add 'tools:replace="android:splitName"' to <activity>
element at AndroidManifest.xml:68:9-71:75 to override.
......./base/src/main/AndroidManifest.xml:74:13-46 Error:
Attribute activity#com.github.gorbin.asne.core.OAuthActivity#splitName value=(feature_match) from [:feature_match] AndroidManifest.xml:74:13-46
is also present at [:feature_topvoters] AndroidManifest.xml:77:13-50 value=(feature_topvoters).
Suggestion: add 'tools:replace="android:splitName"' to <activity> element at AndroidManifest.xml:72:9-75:80 to override.
So basically the issue appears when i try to add the same library in both 2 feature modules. What do i need to tell the manifest to prevent this merge conflict.
Both manifest files from the feature modules are empty. It must be the thirdparty manifest files causing the issue.
I thought the multiple feature/module structure would increase the architecture. But by now i really think it is way easier to have one big module. There are just too many issues in the whole gradle build model.
Ok after 10 hours of trying to find a solution i came up with the following:
I cloned the library causing the issue (Facebook).
Instead of compiling against maven i created a new library and put the complete source of the facebook SDK inside.
Inside the manifest.xml from that facebook SDK, there is an activity defined:
<activity
tools:replace="android:theme"
android:name="com.facebook.LoginActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
/>
I removed the activity from the manifest.xml and moved the activity definition into the main app manifest.xml
In this way the manifest merger will not try to merge two of the same activity definitions, but uses the one defined in the main app.
Works. But it is a shitty solution of course.
Not sure if this a bug in the build process. I have spend over 20 hours trying to fix this. Cannot find a way.
Multi module applications are not easy to construct.
I am working in an app which is already in live.Now i have added new features in it.I am trying to create a signed apk after adding the new features but it shows error on the existing modules,But the existing modules work good in live While creating signed apk getting errors from old modules what is the reason for the errors and i Need to know how to create a signed apk for my modified project
E:\updated one\Wed Studio\app\src\main\AndroidManifest.xml:842: Error: The <activity> element must be a direct child of the <application> element [WrongManifestParent]
<activity
^
E:\updated one\Wed Studio\app\src\main\AndroidManifest.xml:845: Error: The <activity> element must be a direct child of the <application> element [WrongManifestParent]
<activity
^
Explanation for issues of type "WrongManifestParent":
The <uses-library> element should be defined as a direct child of the
<application> tag, not the <manifest> tag or an <activity> tag. Similarly,
a <uses-sdk> tag much be declared at the root level, and so on. This check
looks for incorrect declaration locations in the manifest, and complains if
an element is found in the wrong place.
Well, While asking a question in SOF you should be more specific. As per the communication over comments, in your project you don't have any compile time / run time error's in your project but still your unable to export a signed apk for your project.
This is a wired situation discussed here Android Export aborted This may be because of the lint errors in your project you can check in "Problems" view, or the "Lint Warnings" view.
If it is the case, To solve issue:
Project -> properties,
find Android Lint Preferences, in top to right click configure
workspace settings... -> unclick "Run full error check when exporting
app", apply done.
or
Window>Preferences>Android>Lint Error Checking
uncheck Run full error check when exporting app
I'm trying to test using the following directory structure (which was setup by Android Studio):
I can run some tests just fine, and even the AllTests.java runs fine without the AndroidManifest.xml file even being there. The thing is, for one of my new tests, I need the android.permission.INTERNET permission. So, I added the following to the AndroidManifest.xml file located within the androidTest directory:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.core"
android:versionCode="2"
android:versionName="2.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Unfortunately, this doesn't work. I'm still getting the following error when I run one of my tests:
E/RestAPIRequestTest﹕ Permission denied (missing INTERNET permission?)
I've tried setting the package to be com.example.core.test in my AndroidManifest.xml file (since that is what it shows up as in my Settings->Apps list), but with no joy.
I'm thinking it's not even recognizing the AndroidManifest.xml file, since the version number doesn't show in the Settings for the test app, either.
How can I inject the correct permissions for my test project?
I needed to do something similar. I created a folder named "debug" next to androidTest, which corresponds to the debug variant of the app, and put an AndroidManifest.xml with the permission in that folder. Then the permission works under test since the test app uses the debug variant. It's not ideal because it blurs the line between test and debug, which aren't quite the same thing.
I think what's happening is that the permissions in androidTest/AndroidManifest.xml are going to the test app, not the target app, although it's not 100% clear to me if there are actually two different APKs or what.
In older versions of Android Studio and the Android Gradle plugin the androidTest/AndroidManifest.xml file was ignored. This was documented at the tools.android.com site at the time.
With the Android Studio 1.0+ and Android Gradle 1.0+ plugin launch in December 2014 the AndroidManifest.xml file should now be merged with the normal main/AndroidManifest.xml files (in addition to the debug and release manifest files if they exist). More details regarding the manifest merging rules are here.
If you still run into issues or are just debugging manifest related testing issues try this
(Adapt this slightly for Windows):
Drop to a terminal
change to to your project directory
cd MyApplication
Build your project, assuming 'debug' is the build type you want to test with, but you could also be testing with 'release' or a build script defined one.
./gradlew assembleDebugTest
Then inspect your test APK manifest:
ls app/build/intermediates/manifests/test/debug/AndroidManifest.xml
View your application APK manifest:
ls app/build/intermediates/manifests/full/debug/AndroidManifest.xml
A merge output log can be found detailing the manifest merging process:
ls app/build/outputs/apk/manifest-merger-debug-report.txt
A couple of extra notes:
An instrumentation element is automatically added to your test APK's AndroidManifest.xml so you should only be adding extra activities, permissions, etc that your test APK needs.
If testing with mock locations your application APK will need the ACCESS_MOCK_LOCATION permission. You can add the permission to your debug/AndroidManifest.xml file or you can define that the test APK and the application APK should use the same userId when deployed (sharedUserId attribute in your AndroidManifest.xml).
This is a known problem.
Currently (AGP <= 3.4.X) is not supporting AndroidManifest test merging.
This is reported here: https://issuetracker.google.com/issues/127986458
and here there is the issue created by one of the Roboelectric maintainers.
The workaround as described here its near the same proposed by user3286293 and currently is the only way to have the manifest merged for testing purposes.
Hope to see a fix for AGP 3.5 or 3.6
As specified here, during instrumented tests, there are generated two .apk files. If you take a look, the smaller one it's most probably the one named app-debug-androidTest-unaligned.apk and it actually does include the provided permissions.
Inspecting the file with aapt d permissions <apk_file_path>.apk can be useful to see a list of all of them.
Now, there might be an issue with the context itself where the permission is requested. I had a similar problem, trying to write some screenshots on SD card (thus needing the WRITE_EXTERNAL_STORAGE permission).
This answer helped me to fix the problem, although I cannot fully understand why it's necessary.
In few words, you'll need to declare the same android:sharedUserId in both manifests, in order to merge the permissions when both apks are installed on the same device - that happens when tests are running.
This helped me to separate permissions needed just for testing from the one in production.
You need to define that in build.gradle file:
android {
sourceSets {
androidTest.manifest.srcFile "src/androidTest/AndroidManifest.xml"
}
}
One solution would be like build main apk and test apk in single run.
Example: ./gradlew clean :main:assembleDebug :main:assembleDebugAndroidTest.
This will create a new instrumented main application which has all extra permissions required for test application.
The docs state:
As mentioned previously, next to the main sourceSet is the androidTest sourceSet, located by default in src/androidTest/
....
The sourceSet should not contain an AndroidManifest.xml as it is automatically generated.
So, if I want to add extra permissions for the tests, what is the correct way to do it?
As of version 0.13.0 (released 2014/09/18) of the Android Gradle plugin it is now possible to have a custom manifest for Android tests.
It is now possible to provide a manifest for test apps (src/androidTest/AndroidManifest.xml)
Source: https://sites.google.com/a/android.com/tools/tech-docs/new-build-system
For more information see the sample "gradle_examples_0.14.4/tree/master/androidManifestInTest" - although it seems to me that there's no special configuration needed.