Failure INSTALL PARSE FAILED MANIFEST MALFORMED - android

I am getting a strange issue while installing application.
When I compiling my project there is no error but when I trying to launch its shows me,
Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED Error.
I have tried so many thing related Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error and also follow that rule but something goes wrong.
<manifest
android:hardwareAccelerated="true"
android:versionCode="1"
android:versionName="0.0.1"
package="Work.Work"
xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:hardwareAccelerated="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:supportsRtl="true">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="#string/activity_name"
android:launchMode="singleTop"
android:name="MainActivity"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.DeviceDefault.NoActionBar"
android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:exported="true"
android:name="com.plugin.gcm.PushHandlerActivity" />
<receiver
android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="Work.Work" />
</intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />
<activity
android:exported="true"
android:name="com.adobe.phonegap.push.PushHandlerActivity" />
<receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler" />
<receiver
android:exported="true"
android:name="com.google.android.gms.gcm.GcmReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<service
android:exported="false"
android:name="com.adobe.phonegap.push.GCMIntentService">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:exported="false"
android:name="com.adobe.phonegap.push.PushInstanceIDListenerService">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:exported="false"
android:name="com.adobe.phonegap.push.RegistrationIntentService" />
</application>
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission
android:name="Work.Work.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<!--<uses-permission android:name="Work.Work.permission.C2D_MESSAGE" />-->
<!--<uses-permission android:maxSdkVersion="18" android:name="android.permission.WRITE_EXTERNAL_STORAGE" />-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<!--<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />-->

I was having this error because i had capital letters in my package name like this.
Com.Droider.packagename;
After i had changed it to something like:
com.droider.packagename;
In your case try to change it to:
work.work;
EDIT 1 :
May be this causes also.
android:name="MainActivity"
Change this to.
android:name=".MainActivity"

It May cause for Android 12 . For this
Add exported = true in your Activity
Example :
<activity
android:exported="true" />

Just check all the
android:name="..."
in your manifest and see if you forgot to put a dot in the beginning of a name that should have it, mostly names of your classes.

package="Work"
APK manifest package names must contain at least one . separator in them. For example:
package="work.work"
You can read the PackageParser source to learn about various ways installation can fail with INSTALL_PARSE_FAILED_MANIFEST_MALFORMED.

In my case, i put ':' on value of android:process
<service
android:name=".Views.Views.services.MyService"
android:process=":remote" />
It works for me

I had the same problem. I had create a new package Start with capital letter. Its leads to this same problem . Check your all package folder names and be sure all in small letters.
Happy coding

<activity
android:exported="true" />

in my case
if you have changed your activity to fragment
then remove that activity name from your androidmanifest.xml file
<activity
android:name=".fragment_change_password"
android:screenOrientation="portrait" />
remove this type of lines from manifest file

Your package name has a capital letter in it. Try refactoring your package so that all the letters are lowercase. To do this, in the panel for your project, make sure you're in Android view mode, then click the gear that is a little to the right of the view indicator, then make sure compact empty middle packages is unchecked. Next, right click on your package with a capital letter in it and select refactor -> rename. Change it to have a lower case, double check your AndroidManifest.xml is now a lower case, if not, manually edit it.

In manifest file meta data tag will be available for each xml resource file .
If that meta data doesn't have android:resource location , this issue will arise .
Example :
<meta-data android:name="com.google.android.actions"
android:resource="#drawable/cellphone"/>

in my case place i placed Application class outside side main package folder.
just move Application class to root activities folder.

Related

Problem with android manifest when creating flutter appbundle

I have a problem with the android xml file when creating the appBundle. However, I cannot find the problem, could anyone help me please? I have never removed anything from the file. I have never really worked with manifest files before, so I wasn't completely sure what I was looking for.
Thanks in advance
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="-----------------">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name=".Application"
android:label="Pravachaka Sabdam"
android:icon="#mipmap/ic_launcher"
android:usesCleartextTraffic="true">
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:showWhenLocked="true"
android:turnScreenOn="true"
>
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<uses-permission android: name="android.permission.INTERNET" android:maxSdkVersion="28" />
</manifest>
Error Message
Error parsing LocalFile: 'A:\Flutter\BETA TEST FOLDER\Android\one\android\app\src\main\AndroidManifest.xml' Please ensure that the android manifest is a valid XML document andtry again.
Ok, you have a space character between android and name while defining internet permission. You need to remove that:
<uses-permission android:name="android.permission.INTERNET" android:maxSdkVersion="28" />
I was able to find the issue.
The issue was that there was an unnecessary space after android here:
<uses-permission android: name="android.permission.INTERNET" android:maxSdkVersion="28" />
I changed this to :
<uses-permission android:name="android.permission.INTERNET" android:maxSdkVersion="28" />

ERROR getting 'name' attribute: attribute is not a string value

Uploading my apk file to google play makes this error:
Your APK cannot be analyzed using aapt. Error output: Failed to run
aapt dump badging: ERROR getting 'name' attribute: attribute is not a
string value
Since I know that this problem is within my manifest file, I have put it here:
AndroidManifext.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ir.altontech.newsimpay">
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<permission
android:name="ir.altontech.newsimpay.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="ir.altontech.newsimpay.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application xmlns:tools="http://schemas.android.com/tools"
android:name="ir.altontech.newsimpay.Classes.Model.AnalyticsApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/AppTheme"
tools:replace="android:supportsRtl">
<receiver
android:name="com.adjust.sdk.AdjustReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<receiver android:name=".Receivers.SmsListener">
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<receiver
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false" />
<activity
android:name="ir.altontech.newsimpay.Activities.Introduction"
android:screenOrientation="portrait" />
<activity
android:name="ir.altontech.newsimpay.Activities.Main"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:taskAffinity="ir.altontech.simpay"
android:theme="#style/AppTheme"
android:windowSoftInputMode="adjustPan"/>
<activity
android:name=".Activities.SpecificPage"
android:screenOrientation="portrait">
<intent-filter>
<data
android:host="ir.altontech.simpay.specific"
android:scheme="simpay" />
<data
android:host="ad.simpay.ir"
android:scheme="http" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Activities.SplashActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:taskAffinity="ir.altontech.simpay"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Activities.FastCharge"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:taskAffinity="ir.altontech.simpay"
android:theme="#style/fast_charge_theme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name="ir.altontech.newsimpay.Activities.BarcodeScanner" />
<activity
android:name="ir.altontech.newsimpay.Activities.FinalTrainTicket"
android:screenOrientation="landscape" />
<activity
android:name="ir.altontech.newsimpay.Activities.VideoPlayer"
android:screenOrientation="landscape"
android:taskAffinity="ir.altontech.simpay" />
<activity android:name="ir.altontech.newsimpay.Activities.CallBack">
<intent-filter>
<data
android:host="ir.altontech.simpay.callback"
android:scheme="simpay" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service
android:name=".Classes.Services.GCMService"
android:exported="false" />
<receiver
android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.CampaignTrackingService"
android:enabled="true"
android:exported="false" />
<!-- services -->
<!-- registration process service -->
<service
android:name="ir.altontech.cloudmessaging.core.registrationprocess.RegistrationProcessService"
android:exported="false">
<intent-filter>
<action android:name="co.shariftech.pushnotification.intent.action.START_PUSH_NOTIFICATION_SERVICE" />
</intent-filter>
</service>
<!-- registration process token refresher service -->
<service
android:name="ir.altontech.cloudmessaging.core.registrationprocess.RegistrationProcessTokenRefresherService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<!-- push notification service -->
<service
android:name="ir.altontech.cloudmessaging.core.pushnotification.PushNotificationService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<!-- receivers -->
<!-- google cloud messaging receiver -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="ir.altontech.newsimpay" />
</intent-filter>
</receiver>
</application>
</manifest>
I have checked all android:name attributes and couldn't find the problem. Thank you all.
so after searching a little I have found three options for you to do:
1- if you have something as follows (which I see you don't ):
<intent-filter>
<action android:name="#string/alarm_auto_sync" >
</intent-filter>
you should hard code the string and remove #string
2- follow this bug to see what could and have been done to solve this issue as I found out this might be the bug of
aapt dump badging
3- if you have values-fa and values-en and other string values as such you should copy your android:name to values.
for more information on these options visit this question or this question
hope this helps
You can go for below suggested link. I hope it helps you.
aapt ERROR getting 'android:name' attribute: attribute is not a string value
Thank you
I think this issue is for different reasons for different people. But in all cases it is the android:name attribute that needs to be investigated. When I encountered it and read some of the replies here, I found mine. Adding it here, just so that it can help someone in future.
<intent-filter>
<action android:name="#string/broadcast_action" />
</intent-filter>
I had defined broadcast_action in strings.xml It worked when I changed that to a hardcoded string. AAPT does not accept a string reference here.
All thing seems good in your AndroidManifest.xml except xmlns:tools="http://schemas.android.com/tools" position. Please give a try by moving xmlns:tools="http://schemas.android.com/tools" from <application></application> tag to <manifest></manifest> tag like this.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ir.altontech.newsimpay"
xmlns:tools="http://schemas.android.com/tools">
<application
android:name="ir.altontech.newsimpay.Classes.Model.AnalyticsApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/AppTheme"
tools:replace="android:supportsRtl">
</application>
Hope this will work for you :)
check this link from google
android:name="string"
the document says , your syntax of android:name element should be String .
i think , your manifest file project is good . check your manifest library .maybe you add some library and get this error . also check your project and your library have android:name element .
hope this help you .
This is how you have defined your custom permission:
<permission
android:name="ir.altontech.newsimpay.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
But in the docs you can see:
You need to supply both a label and description for the permission.
I'm not sure whether this may be the case, but at least docs urge you to define label and description.
If you are using any library project as module in your project that having
android:label="#string/app_name"
in their string.xml file then it may coause of your problem.
So your pass hardcode app name in your manifest file for app name like below.
android:label="PASS YoUR APP NAME HERE not from string.xml"
If your app is multi-lingual, then make sure you have provided the translatable as false in the string.xml or provide the app_name in the other files as well. I too got this error once and that was the cause.
may be on of your class had been moved to another package check if all of your classes are in the same package path like manifest
android:name="ir.altontech.cloudmessaging.core.pushnotification.PushNotificationService"
First of all, try to follow java naming convention
Since from your code I cant realy tell is your Application Class an Enclosing class
Try using .Classes.Model.AnalyticsApplication instead of ir.altontech.newsimpay.Classes.Model.AnalyticsApplication
For me the issue was that the broadcast intent-filter name which was referenced from the string file was deleted.
If you are using multi-module project check all manifest in Android Studio to see an error. android:name can refer to any android:name attribute, not just the one in application tag.
Merged manifest can be found at
app/build/intermediates/merged_manifest/<flavour>
In Android we need to assign the strings through string.xml file.
String name - "xyz app"
this is not the recommended approach
String name = "#string/app_name"
In String.xml Store this name as
<string name="app_name">xyz app</string>
complete in android programming we need to follow this approach for using strings

OUTDATED DEVICE: Parse Push Notification to Android devices

Hi have worked with parse for saving data. But notification is something i am stuck with. I am not able figure out what's going wrong.
I have done all the receiver registrations and so my device also gets registered in the installation table but while sending push from web console it says "push sent 0" looking into the description of each push it shows that "OUTDATED DEVICE - The records on this installation are outdated, the user might have uninstalled the app." But I just did the registration.
I am going mad with this...no clue in what am I doing wrong, I am using eclipse IDE, Can anyone please suggest me any Solution??
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.parsecomlogin"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.example.parsecomlogin.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.parsecomlogin.permission.C2D_MESSAGE" />
<permission
android:name="com.example.parsecomlogin.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.parsecomlogin.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<application
android:name=".ParseApp"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
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>
<!-- Added for Parse push notifications -->
<!-- My custom receiver -->
<receiver
android:name=".ParseReceiver"
android:enabled="true"
android:exported="false" >
<intent-filter>
<action android:name="com.example.parsecomlogin.RECEIVE_PUSH" />
</intent-filter>
</receiver>
<!-- END my custom receiver -->
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.example.parsecomlogin" />
</intent-filter>
</receiver>
<activity
android:name=".Welcome"
android:label="#string/title_activity_welcome" >
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_login" >
</activity>
<activity
android:name=".LoginSignupActivity"
android:label="#string/title_activity_login_signup" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDZ5TG28QJnN5zMyIdezPllvrfrwg7ElQs" />
</application>
</manifest>
I faced exactly the same problem and I fixed it a few minutes ago by coincidence. I hope the problem can be solved with the same touch-up for you as well.
In my situation, I used one of the older projects I worked and I have changed manifest package name manually in a way. In AndroidManifest.xml file, the manifest package name was changed to "com.myprojectname". There was no problem and app can run without any error with this package name. Also, all of Parse features run problem-free except push notification service. Then I checked other paths with Ctrl + Shift + R and searched whether R.java uses the same name. Unsurprisingly, the package name was identical in this file but I realized that in the lines below R.java uses the pattern of "net.myprojectname.app" instead of "com.myprojectname". I replaced "com.myprojectname" with "net.myprojectname.app" in all files by using Ctrl + Shift + R again. I think it was not the cause of the problem but I tried to send a last push notification desperately. It is hard to believe but it is worked. I got the notification successfully after all.
I answered the question in a highly informal and non-technical way but I have no idea about the underlying cause, I just want to help. Maybe it works for you. Good luck.

Registering a content provider

I have been trying to create a copy of Android's ContactsProvider. I wanted to make minimal changes to the provider as most of my work will be in another app which will use the data. However, I want to ensure the real contacts are not accessible to the app I am making so I planned to create a copy of the provider. After successfully navigating though the process of creating a copy provider with a different authority, I tried to call my copied provider. At this point I got two errors.
The first one was in my own app where I got the error "Failed to find provider info for 'ContentProvider'" I read this answer for that but I had taken care of everything mentioned here already.
The second error happens in my provider: java.lang.NoClassDefFoundError: com.google.common.collect.ImmutableSet$Builder This is probably the reason why I am getting the first error. Because my provider is never able to access the classes that are internal to Android, it is not getting registered as a valid provider and thus my app is not able to "find" the provider.
Here is my Manifest file for the ContactManager:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prajitdas.contactmanager"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.prajitdas.contactmanager.ContactManager"
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="ContactAdder" android:label="#string/addContactTitle">
</activity>
</application>
</manifest>
and the manifest file for the ContactsProvider:-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prajitdas.android.providers.contacts"
android:versionCode="2"
android:versionName="2.0">
<permission
android:name="com.android.voicemail.permission.READ_WRITE_ALL_VOICEMAIL"
android:label="#string/read_write_all_voicemail_label"
android:description="#string/read_write_all_voicemail_description"
android:permissionGroup="android.permission-group.PERSONAL_INFO"
android:protectionLevel="system|signature"
/>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BIND_DIRECTORY_SEARCH" />
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" />
<uses-permission android:name="com.android.voicemail.permission.READ_WRITE_ALL_VOICEMAIL" />
<application android:process="android.process.acore"
android:label="#string/app_label"
android:icon="#drawable/app_icon"
android:allowBackup="true">
<!-- Modified provider authority -->
<provider android:name="ContactsProvider2"
android:authorities="fakecontacts;com.prajitdas.android.providers.contacts"
android:label="#string/provider_label"
android:multiprocess="false"
android:exported="true"
android:readPermission="android.permission.READ_CONTACTS"
android:writePermission="android.permission.WRITE_CONTACTS">
<path-permission
android:pathPrefix="/search_suggest_query"
android:readPermission="android.permission.GLOBAL_SEARCH" />
<path-permission
android:pathPrefix="/search_suggest_shortcut"
android:readPermission="android.permission.GLOBAL_SEARCH" />
<path-permission
android:pathPattern="/contacts/.*/photo"
android:readPermission="android.permission.GLOBAL_SEARCH" />
<grant-uri-permission android:pathPattern=".*" />
</provider>
<provider android:name="CallLogProvider"
android:authorities="fakecall_log"
android:syncable="false" android:multiprocess="false"
android:exported="true"
android:readPermission="android.permission.READ_CALL_LOG"
android:writePermission="android.permission.WRITE_CALL_LOG">
</provider>
<provider android:name="VoicemailContentProvider"
android:authorities="com.prajitdas.android.voicemail"
android:syncable="false" android:multiprocess="false"
android:exported="true"
android:permission="com.android.voicemail.permission.ADD_VOICEMAIL">
</provider>
<!-- Handles database upgrades after OTAs, then disables itself -->
<receiver android:name="ContactsUpgradeReceiver">
<!-- This broadcast is sent after the core system has finished
booting, before the home app is launched or BOOT_COMPLETED
is sent. -->
<intent-filter>
<action android:name="android.intent.action.PRE_BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<receiver android:name="PackageIntentReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<data android:scheme="package" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<receiver android:name="LocaleChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.LOCALE_CHANGED"/>
</intent-filter>
</receiver>
<service android:name="VoicemailCleanupService"/>
<activity android:name=".debug.ContactsDumpActivity"
android:label="#string/debug_dump_title"
android:theme="#android:style/Theme.Holo.Dialog"
>
<intent-filter>
<action android:name="com.prajitdas.android.providers.contacts.DUMP_DATABASE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<provider android:name=".debug.DumpFileProvider"
android:authorities="com.prajitdas.android.providers.contacts.dumpfile"
android:exported="true">
</provider>
</application>
</manifest>
As you can see, I have basically copied the original manifest files and modified it to the new authorities for my provider. I have done the same for the java code, but it is too big to post here. If anyone can help me identify the steps to either make the android internal calls work or maybe resolve the first problem of "registering" the provider on a phone somehow, it would be much appreciated.
com.google.common.collect.ImmutableSet$Builder isn't actually an internal Android class. It is a part of the Google's Guava library. You need to add Guava's JAR as a dependency to your project to compile it (and, probably, some others dependencies, check the list for the ContactsProvider in its Android.mk).
The actual way of adding JAR dependency varies depending on what do you use for building your app (e.g. Ant, Maven, Gradle, or Eclipse).

Android StackWidget unable to bind

I am currently trying to add a widget to my application and have been basing my implementation on this code http://developer.android.com/resources/samples/StackWidget/index.html
I have put all my stack widget related classes in their own package within my main package.
When I try to add the widget it is unable to bind and hence the cards are not displayed (it just states the default text "This is the empty view")
Below is my manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bencallis.dealpad" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:icon="#drawable/ic_launcher"
android:logo="#drawable/logo" android:theme="#style/DealPadTheme"
android:hardwareAccelerated="true" android:uiOptions="splitActionBarWhenNarrow">
<activity android:label="#string/app_name" android:name=".DealPadActivity"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SettingsActivity" />
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<!-- Widgets -->
<receiver android:name=".stackwidget.StackWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/stackwidgetinfo" />
</receiver>
<service android:name="stackwidget.StackWidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS"
android:exported="false" />
</application>
</manifest>
Error message:
E/RemoteViewsAdapterServiceConnection(474): bind(): Unknown component ComponentInfo{com.bencallis.dealpad/com.bencallis.dealpad.stackwidget.StackWidgetService}
I am sure there is a simple mistake somewhere which is making the component info repeat com.bencallis.dealpad.
Any ideas?
It turned out it was to do with my manifest and a problem locating the service. I was missing a . in the name (which gives it the path).
Silly mistake!

Categories

Resources