Issue with AndroidManifest.xml in Android Studio 3.0 [duplicate] - android

This question already has answers here:
AAPT2 error: check logs for details: unknown element <action> found
(2 answers)
Closed 5 years ago.
I recently installed Android Studio 3.0 from the Canary channel. However, loading my old projects, this keeps on popping up in the AndroidManifest.xml file that's automatically generated depending on the build variant:
Error:(49) unknown element <uses-sdk> found
This also is displayed:
Error:/home/computername/AndroidStudioProjects/applicationname/app/build/intermediates/manifests/full/release/AndroidManifest.xml:49 unknown element <uses-sdk> found
Needless to say, this wasn't an issue in Android Studio 2.3. Any ideas on how to solve this? I've read a handful of similar issues here but none solved my problem. By the way - it doesn't matter if I set the build variant to debug or release, it says the same thing. Also, the "R" class doesn't work, and if I hover over the manifest xmlns:android="http://schemas.android.com/apk/res/android declaration, it says "URI is not registered".
Again, the project structure hasn't changed at all, I've only upgraded to Android Studio 3.0.
Thanks!
Here's the AndroidManifest.xml file that is under the /src/main folder, which works perfectly fine. The problem is with the generated AndroidManifest.xml files in the /app/build/intermediates/manifests/full folder - THESE are the ones that break my app.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain.appname">`
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".view.MainActivity"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".view.TabbedActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation|screenSize"
android:noHistory="true">
</activity>
</application>
<!-- PROTECTION_NORMAL permissions, automatically granted -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- DANGEROUS PERMISSIONS, must request -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Here's the way the debug or release auto-generated Manifests that don't work look like:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain.appname"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="25" />
<!-- PROTECTION_NORMAL permissions, automatically granted -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- DANGEROUS PERMISSIONS, must request -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<meta-data
android:name="android.support.VERSION"
android:value="25.3.1" />
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name="com.domain.appname.view.MainActivity"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.domain.appname.view.TabbedActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="#string/app_name"
android:noHistory="true"
android:screenOrientation="landscape"
android:theme="#style/AppTheme.NoActionBar" >
</activity>
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="25" />
</application>
</manifest>
Later edit
I've went back to Android Studio 2.3, and set the gradle plugin back to 2.3.2, and here's how the automatically generated AndroidManifest.xml looks like now:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain.appname.test" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="26" />
<instrumentation
android:name="android.support.test.runner.AndroidJUnitRunner"
android:functionalTest="false"
android:handleProfiling="false"
android:label="Tests for com.domain.appname"
android:targetPackage="com.domain.appname" />
<application>
<uses-library android:name="android.test.runner" />
</application>
</manifest>
Now everything works as usual, however, note the difference between the automatically generated Manifest file under gradle 3.0.0 and the one under gradle 2.3.2
I guess I'll have to wait until someone finds a solution to make this work under gradle 3.0.0 and in the meantime use the gradle plugin 2.3.2 in Android Studio 3.0 (which I'm doing right now and it works).
So the issue is with the new gradle 3.0.0-alpha9

You probably have a dependency library (aar) that has a <uses-sdk> inside the application tag in the manifest. So when that gets merged, your app will have the incorrect usage also.
This happened to me with an old local build of vlc for Android.

I had a category element in my Manifest file inside a regular activity which was causing build failure. removing it after updating to as3-rc1 and build tool 26+ my issue was resolved. Hope this helps someone.
<activity
android:name=".AboutUsActivity"
android:label="#string/title_activity_about_us"
android:parentActivityName=".MainActivity"
android:theme="#style/AppTheme.NoActionBar">
<category android:name="android.intent.category.DEFAULT" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.MainActivity" />
</activity>

if problem remains, please check this official tutorial on migrate to Gragle plugin v. 3.0.0.
Got the same error, in my case there was typo in meta_data instead of meta-data in the Manifest file preventing a build.

Related

Error: unknown element <provider> found

I am trying to follow the tutorial here : https://developer.android.com/training/camera/photobasics.html#TaskPath
to make an application using the camera and taking photos. At one point, it is explained that a provider must be provided (ahah) in the manifest to store the picture we took with the camera.
Here is my problem, the provider is not recognize at compilation and my build fail. I learn by searching that apparently, this error means my tag is misplaced. Well... If I move it it Android SMARTLY (yes this is ironic) regenerate it here without asking anything. And obvioulsy fail it's build.
Here is my manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.matthieu.projet"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="25" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.android.fileprovider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths" />
</provider>
<meta-data
android:name="android.support.VERSION"
android:value="25.3.1" />
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:testOnly="true"
android:theme="#style/AppTheme" >
<activity android:name="com.example.matthieu.projet.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="com.android.tools.ir.server.InstantRunContentProvider"
android:authorities="com.example.matthieu.projet.com.android.tools.ir.server.InstantRunContentProvider"
android:multiprocess="true" />
</application>
</manifest>
Let me know if you need any more information.
You are editing the wrong manifest file. Ignore the one that pops up in the IDE, as that is one that is generated as part of the build process and displayed erroneously, courtesy of this three-year-old Android Studio bug.
Go back into your module and edit the original manifest.
See this blog post for more.

Android Studio rendering Error

So I just tried to render one of my xml views and I got this error:
Exception raised during rendering: Binary XML file line #-1: No start tag found!
Any ideas? I've included the manifest file below______________________________
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.adrian.trucktracker">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/legionicon"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Locator"
android:label="#string/title_activity_locator" >
</activity>
</application>
</manifest>
Since I cannot comment yet, I'm posting this as a reply.
This seems to be a bug in Android Studio where when you edit the xml file directly, it doesn't update in it's graphical layout yet. The issue has been raised and I don't think it has been corrected yet. Here's the issue for you to upvote.
For now, though you don't need to restart the entire Android Studio. Just close the tab and reopen it from the project navigation pane. It'll load correctly. It'll save you a lot of time.
Closing the tab was quite dramatic for me since I had very very many files in my project.
Moving the problematic tab between different split views did the trick in a second.

After minor refractoring existing android application to new project, home screen icon got removed

I had my existing android project going unmanageable due to unnecessary research codes, so I decided to create a new project with only necessary code that's required for the app. I uploaded the same on play store's beta environment. As the app got updated on my phone, the already existing app icon on home screen got removed. Did I make any mistake in the code development?
Please help
EDIT: Added Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.abc"
android:installLocation="preferExternal"
android:versionCode="52"
android:versionName="5.0.004" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name="com.example.abc.Appname"
android:allowBackup="true"
android:icon="#drawable/launcher"
android:label="#string/app_name"
android:theme="#style/Theme.CustomTheme" >
<activity
android:name="com.example.abc.SplashScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/title_activity_app_name"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</manifest>
Reverted back the application name to old file name (java class) and the same in manifest file. The launcher icon was created while installing via Google play store's beta environment.
Still unsure why the application name and java class names had an impact on the launcher icons. Any idea?

Unable to instantiate application - AndroidManifest settings

We have recently developed an Android app and published it via Google Play. First of all we created a beta test group, added members to it and got feedback etc from each and everyone of them. We had no problems publishing and installing this beta version on the users devices.
We promoted this beta version (API level 14+) to production and suddenly the app started to fail after installing with the following error:
java.lang.RuntimeException: Unable to instantiate application x.x.x.App:
java.lang.ClassNotFoundException: x.x.x.App
In the AndroidManifest file the name attribute of Application was the full packagename x.x.x.App. We changed this to be just the class name App and everything started to work smoothly.
However the customer decided to make the app compatible with API 10 - 13 and we made the changes to AndroidManifest file accordingly. We just changed the minSDK=10. Again we had the beta testing process with no further errors etc.
We then decided to promote this app to production and now we get the same error
java.lang.RuntimeException: Unable to instantiate application x.x.x.App:
java.lang.ClassNotFoundException: x.x.x.App
again when installing/upgrading to this new version.
What on earth is going on here - I need an explanation (if it exists) since I am not able to find any meaning of this?
EDIT: The manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.expatindenmark.adquota"
android:versionCode="8"
android:versionName="3.2" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name="App"
android:allowBackup="false"
android:icon="#drawable/ic_launcher_hoejtid_ikon"
android:label="#string/app_name" >
<activity
android:name="com.expatindenmark.adquota.SplashActivity"
android:configChanges="locale"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.expatindenmark.adquota.AdquotaTabActivity"
android:configChanges="locale"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar" >
</activity>
</application>
</manifest>
As stated in an earlier comment I changed name = "App" to name = ".App" and that works.

Problems publishing app android

I have a "little" app on market, and uploaded a new version of it, but when I upload the apk this message appears:
This setting can not be published for the following reasons:
The version 2 is not available on any device configuration: every device that can receive version 2 receives version 3.
and the state of the 3rd version is "draft in final phase"
How can i fix it?
I put the Manifest if can be helpfull
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shudy.lightson"
android:versionCode="3"
android:versionName="1.1.1" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:debuggable="false"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.shudy.lightson.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
<meta-data android:value="aXXXXXXXXXXX2" android:name="ADMOB_PUBLISHER_ID" />
</activity>
</application>
</manifest>
It's all good. This is how Google Play works. It's just saying that the new version will work for all the devices that are support by older versions. So the old version is obsolete and should be deactivated.
Deactivate the old version and all will be fine.

Categories

Resources