Android Studio rendering Error - android

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.

Related

how to merge these two AndroidManifest files

I am currently using this AndroidManifest in my project: Current Manifest, however I am trying to use this other AndroidManifest from a website in order to implement an image upload service : Manifest to add
I have been searching for answers but I haven't been able to merge these 2 files successfully. The Current Manifest picture of course is not the entirety of it, but I simply showed you the most important parts. Am I able to merge both packages, with both applications and activities?
current manifest
<manifest
package="org.briarproject.briar"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.hardware.bluetooth"/>
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<application
android:name="org.briarproject.briar.android.BriarApplicationImpl"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher_round"
android:label="#string/app_name"
android:logo="#mipmap/ic_launcher_round"
android:theme="#style/BriarTheme">
<activity
android:name="org.briarproject.briar.android.reporting.DevReportActivity"
android:excludeFromRecents="true"
android:exported="false"
manifest to add
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.simplifiedlearning.volleymysqlexample">
<!-- the internet permission -->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Do you still want to merge them (or still are wondering how to do it, after reading other peoples comments) ?.
If so (you could have used a separate module or make a library), one way is like this:
I kept your old package name as the external main one
I made sure I had all permissions of both manifest's
I kept the new Activity's intent-filter (so it's the first Activity on launch)
You need to physically copy the new source code (directory/s) into your current source code
("net.simplifiedlearning.volleymysqlexample.MainActivity" meaning physically "...\net\simplifiedlearning\volleymysqlexample\MainActivity" {windows path convention})
Merging manifest's is quite a simple operation, merging resources can be a lot of work. Questions you have to ask yourself:
Do I need resources from the new project and copy/merge them into the current ?
(They may be many and incompatible, strings,layouts, styles and themes in particular but many more ...).
Is the build system of the new project merged into your project ?
Example resource directories (not to mention all the files):
res +
+---drawable-hdpi
+---drawable-land-hdpi
+---drawable-land-ldpi
+---drawable-land-mdpi
+---drawable-land-xhdpi
+---drawable-land-xxhdpi
+---drawable-land-xxxhdpi
+---drawable-mdpi
+---drawable-port-hdpi
+---drawable-port-ldpi
+---drawable-port-mdpi
+---drawable-port-xhdpi
+---drawable-port-xxhdpi
+---drawable-port-xxxhdpi
+---drawable-xhdpi
+---drawable-xxhdpi
+---layout
+---menu
+---mipmap-hdpi
+---mipmap-ldpi
+---mipmap-mdpi
+---mipmap-xhdpi
+---mipmap-xxhdpi
+---mipmap-xxxhdpi
+---values
+---xml
The merged manifest:
<manifest
package="org.briarproject.briar"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.hardware.bluetooth"/>
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<application
android:name="org.briarproject.briar.android.BriarApplicationImpl"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher_round"
android:label="#string/app_name"
android:logo="#mipmap/ic_launcher_round"
android:theme="#style/BriarTheme">
<activity android:name="org.briarproject.briar.android.reporting.DevReportActivity">
android:label="#string/crash_report_title"
</activity>
<activity android:name="net.simplifiedlearning.volleymysqlexample.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
your code shows two differentes packages, anyway, merge several manifest is a gradle or IDE task:
"Your APK file can contain just one AndroidManifest.xml file, but your Android Studio project may contain several—provided by the main source set, build variants, and imported libraries. So when building your app, the Gradle build merges all manifest files into a single manifest file that's packaged into your APK."
source: https://developer.android.com/studio/build/manifest-merge.html

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

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.

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?

Package Installer has stopped

I am developing some app for android which worked well untill this evening.
However the app is working well in emulator but on Archos 80 G9 tablet with android 3.2.80 I got this error
The application Package installer (process com.android.packageinstaller) has stopped unexpectedly. Please try again.
Also here is my manifest XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="oni.dani"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="13"
/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:debuggable="true"
>
<activity
android:label="#string/app_name"
android:screenOrientation="portrait"
android:name="com.android.onidani.Dashboard" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.android.onidani.KlasaPrikazBaze"></activity>
<activity android:name="com.android.onidani.Dashboard"></activity>
<activity android:name="com.android.onidani.OniDaniActivity"></activity>
</application>
</manifest>
This error is occuring because you have declared your Dashboard activity twice.
<activity android:name="com.android.onidani.Dashboard"></activity>
You should add permission declaration in your manifest file. E.g
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
error: 'unfortunately package installer has stopped'. This happens when application needs permissions like location, phone call, Read external storage, write external storage etc. If permission is not defined in the manifest file then i get this kind of error message.
Add permission in manifest file according to your need
i need read/write file so i added below permission (outside of application)
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
in my situation i was passing empty array to requestPermissions. so check if your array is'not empty (String[] permissions)

How to set permissions for Android Bluetooth

I'm new to Android development. I'm trying to get a simple HelloWorld app going on my (rooted) phone - and the app is trying to enable Bluetooth.
I've set the Bluetooth permissions in my manifest is as follows, but I'm getting a Permission Denial exception when I try to run the application on my phone via Eclipse:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloandroid"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name" android:debuggable="true" android:permission="android.permission.BLUETOOTH_ADMIN">
<activity android:name=".HelloAndroid"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-sdk android:targetSdkVersion="7" android:minSdkVersion="5"></uses-sdk>
</manifest>
Is there something obvious I'm missing?
The answer about what to include in your manifest.xml for bluetooth activity includes
<uses-feature android:name="android.hardware.bluetooth" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
The first three are of greater priority and as I'm sure you're aware there are different cases when each dependency may be required. Hope it helps with your setup!
I'm not quite sure what the problem was here.
All I can say is that I reinstalled Eclipse and its plugins and now everything is working fine. Thanks for your help Mayra - I'll up-mark your answer because of your helpful and friendly approach.
The element types in the manifest are ordered. I think the uses-permission needs to be first under the tag.

Categories

Resources