Android: java.lang.SecurityException - despite having declared <uses-permission> - android

I'm getting some SecurityException's in my app, presumably due to missing permissions. It happens very rarely and doesn't seem to be consistent, kind of a 'once in a blue moon' thing. I haven't got access to any of the devices that it's crashed on. It seems to happen across different manufacturer, and android versions.
What i've done so far, is check my AndroidManifest.xml for <uses-permission> and that it's in the right scope, as an immediate child of <mainfest> and everything seems fine. Below is my AndroidManifest.xml - shortened a bit for readability. And i've tried to google it, and I've found a similare issue on Google Groups, which also seems to be unsolved: https://groups.google.com/forum/#!topic/android-c2dm/QIjbqO38rHI
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eTilbudsavis.eTilbudsavis" >
<!-- SOME PERMISSIONS E.T.C. REMOVED FOR READABILITY -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- THE PERMISSION'S THAT CAUSES CRASHES -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<application
android:name="com.eTilbudsavis.eTilbudsavis.App"
android:allowBackup="true"
android:icon="#drawable/ic_app"
android:label="#string/app_name" >
<activity
android:name="com.eTilbudsavis.eTilbudsavis.MainActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.eTilbudsavis.eTilbudsavis.test.TestActivity" >
</activity>
<!-- ACTIVITIES, SERVICES, RECIEVERS REMOVED FOR READABILITY -->
</application>
</manifest>
I've included a couple of stack traces, that I have from out crash reporter along with device info.
The first missing com.google.android.c2dm.permission.RECEIVE which is in the manifest. Devices: Sony Xperia Z1 Compact (D5503, running android 5.0.2) and Samsung Galaxy S III (I9300, running Android 4.3).
java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1730)
at android.app.ContextImpl.startService(ContextImpl.java:1707)
at android.content.ContextWrapper.startService(ContextWrapper.java:515)
at com.google.android.gms.gcm.GoogleCloudMessaging.zzs()
at com.google.android.gms.gcm.GoogleCloudMessaging.register()
at com.eTilbudsavis.eTilbudsavis.notification.GcmRegistration.run(GcmRegistration.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Second one is missing android.permission.ACCESS_NETWORK_STATE, which is also defined in the mainfest. Devices: Huawei Ascend P7 (P7-L10, running Android 4.4.2)
java.lang.SecurityException: ConnectivityService: Neither user 10184 nor current process has android.permission.ACCESS_NETWORK_STATE.
at android.os.Parcel.readException(Parcel.java:1475)
at android.os.Parcel.readException(Parcel.java:1429)
at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:843)
at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:635)
at com.eTilbudsavis.eTilbudsavis.ConnectionChecker.isOnline(ConnectionChecker.java:67)
at com.eTilbudsavis.eTilbudsavis.ConnectionChecker.run(ConnectionChecker.java:42)
Third one Second one is missing android.permission.WRITE_EXTERNAL_STORAGE, which is also defined in the mainfest. Devices: Samsung Galaxy Tab S 8.4 (SM-T705, running Android 4.4.2)
java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
at com.google.maps.api.android.lib6.d.t.a()
at com.google.maps.api.android.lib6.d.ft.a()
at com.google.maps.api.android.lib6.d.aj.a()
at com.google.maps.api.android.lib6.d.ai.a()
at com.google.android.gms.maps.internal.x.onTransact(SourceFile:107)
at android.os.Binder.transact(Binder.java:361)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onCreateView()
at com.google.android.gms.maps.SupportMapFragment$zza.onCreateView()
at com.google.android.gms.dynamic.zza$4.zzb()
at com.google.android.gms.dynamic.zza.zza()
at com.google.android.gms.dynamic.zza.onCreateView()
at com.google.android.gms.maps.SupportMapFragment.onCreateView()
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:490)
at com.eTilbudsavis.eTilbudsavis.fragment.LocationMapFragment.ensureSupportMapFragment(LocationMapFragment.java:338)
at com.eTilbudsavis.eTilbudsavis.fragment.LocationMapFragment.onStart(LocationMapFragment.java:676)
at android.support.v4.app.Fragment.performStart(Fragment.java:1813)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:989)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5653)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(NativeStart.java)
Any help is appreciated.

Related

I'm getting error when running my app using android 4.4 and 8.1 (api level 19 & 27) on tablets/mobile phones

This ClassNotFound exception came when I run it on android 4.4 devices, I wonder how did it happen, because I have already registered all of my activities under my manifest file, but still this error is occurring again and it makes me confused.
Please can anyone suggest me what is wrong with my code:
Here is error :
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.Forewarn.ForewarnApp.activities.Splash Activity" on path: DexPathList[[zip file "/data/app/com.Forewarn.ForewarnApp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.Forewarn.ForewarnApp-2, /system/lib]]
Here is manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.Forewarn.ForewarnApp">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<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.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission
android:name="android.permission.MODIFY_PHONE_STATE"
tools:ignore="ProtectedPermissions" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<configuration>
<release>
true
</release>
</configuration>
<permission
android:name="com.Forewarn.ForewarnApp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.Forewarn.ForewarnApp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:name=".activities.SoteriaApplication"
android:allowBackup="false"
android:icon="#drawable/ic_launcherr"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".activities.SplashActivity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name=".activities.SignInActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.SignUpActivity" />
<activity android:name=".activities.ForgotPasswordActivity" />
<activity android:name=".activities.SerachResultsActivity" />
<activity android:name=".activities.DetailsPageActivity" />
<activity android:name=".activities.PropertyDetailsActivity" />
<activity android:name=".activities.BankurptsDetailsActivity" />
<activity android:name=".activities.SampleActivity" />
<activity android:name=".activities.ActivityCallLog" />
<activity android:name=".activities.SettingsActivity" />
<activity android:name=".activities.VehicleDetailsActivity" />
<activity android:name=".activities.ResultsActivity" />
<activity android:name=".activities.OthersActivity" />
<activity android:name=".activities.NoRecordsActivity" />
<activity android:name=".activities.MoreRecordsActivity" />
<activity
android:name=".activities.CriminalDetailsActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.CriminalSampleActivity" />
<activity
android:name=".activities.OtpActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.AddressesDetailsActivity" />
<activity
android:name=".activities.PhonesHistoryDetailsActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.ContactsReaderActivity" />
<activity
android:name=".activities.FingerprintTermsAndConditionsActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.ChangePasswordActivity" />
<activity
android:name=".activities.TermsandConditionsActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.PdfPasswordActivity"></activity>
</application>
</manifest>
and btw i put my minsdkversion = 19
maxsdkversion = 27
and error getting app crashed on android 8.1.0 (api level 27) devices also.
here is my application class code :
public class SoteriaApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
AccountUtils.assignContext(this);
MultiDex.install(this);
}
}
btw i tried with instant run disabling method: now i get verify error : like this :
FATAL EXCEPTION: main
Process: com.Forewarn.ForewarnApp, PID: 1060
java.lang.VerifyError: com/Forewarn/ForewarnApp/activities/SignInActivity
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Sound Like a Multidex issue. In your Application Class activities.SoteriaApplication Add this
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
app.gradle
android {
defaultConfig {
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
}
Enable Multidex in Gradle too
NB : Use android:name=".activities.SoteriaApplication" only if This is Your Custom Appplication Class
Also Try Clean And Rebuild the Project and Run Application without Instant Run. Check Whether problem is resolved
Do one thing-:
Go to File on top menu->Setting->Build Execution->Instant run->If its enabled then try disabling that.
Update2(After reading your updated question and error log)
I have seen that you have verifier log , so let me describe it hope that you can get some clue. Here is this discussion in detail.
This error indicates that the verifier, included in the Java Virtual Machine (JVM), detected a class file that despite well formed, it contains some type of internal inconsistency or faces a security problem.
The VerifyError class extends the LinkageError class, which is used to
indicate those error cases, where a class has a dependency on some
other class and that class has incompatibly changed after the
compilation. Furthermore, the LinkageError class extends the Error
class, which is used to indicate those serious problems that an
application should not catch. A method may not declare such errors in
its throw clause, because these errors are abnormal conditions that
shall never occur.
Finally, the VerifyError exists since the 1.0 version of Java.
For me this could be your case. Consider this SO question and check your dependencies. Clean your project. or even restart your system. I do believe it is not cleaning your project rightly.
Update1
I have the same problem. How I solved it is by adding following line in build.gradle file dependencies.
compile 'com.android.support:multidex:1.0.2'
then in my Application class i extend it with "extends MultiDexApplication" I made sure to add this in onCreate method . like
public class SoteriaApplication extends MultiDexApplication {
//Please extend your application class with MultiDexApplication
#Override
public void onCreate() {
super.onCreate();
AccountUtils.assignContext(this);
MultiDex.install(this);
}}
Please extend you application class with MultiDexApplication class.
If you have done the MultiDex work mentioned by #A.s.ALI and #Tomin B Azhakathu and still have the ClassNotFoundException. Then you should look up if the com.Forewarn.ForewarnApp.activities.SplashActivity is in the main dex(You can drag your apk just in the Android Studio and confirm it). If com.Forewarn.ForewarnApp.activities.SplashActivity is in the main dex, and still throw the exception just let me know, thx.

Cannot get my location using the emulataor

I am trying to develop a Google Map application.
The demo application works fine on a real device but fails on the emulator.
the logcat output is as follows:
java.lang.RuntimeException: Unable to start activity ComponentInfo{il.co.talkie.mapdemo/il.co.talkie.mapdemo.MapDemoActivity}: java.lang.SecurityException: "passive" location provider requires ACCESS_FINE_LOCATION permission.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.SecurityException: "passive" location provider requires ACCESS_FINE_LOCATION permission.
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:606)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:880)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:464)
at il.co.talkie.mapdemo.MapDemoActivity.getMyLocation(MapDemoActivity.java:170)
at il.co.talkie.mapdemo.MapDemoActivity.onCreate(MapDemoActivity.java:106)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Line 170 of MapDemoActivity is
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0,0, this);
The manifest file has these permissions (otherwise it will not work on a real device) as can be seen here:
Manifest.XML
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="il.co.talkie.mapdemo" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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" />
<permission
android:name="com.javapapers.currentlocationinmap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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="#string/google_maps_key" />
<activity
android:name=".MapDemoActivity"
android:label="#string/title_activity_map_demo" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I would like to use the emulator to get my location - it displays the google map and it finds locations of addresses I provide, but it refuses to get my location - so I can not calculate distances properly.
What is wrong?
The emulator I use was created for API 23 and target Google API.
Any help will be welcomed.
If you are using emulator on Android M , you will need to request permission from user despite your manifest. See
ACCESS_FINE_LOCATION permission error emulator only
Android M Google API's to use Google Maps and other permissions
You may check out articles / tutorials e.g. this to work with the new system or just target a lower API <= 22
Error is occuring because of this problem:
Caused by: java.lang.SecurityException: "passive" location provider requires ACCESS_FINE_LOCATION permission.
Just add a new permission to your app manifest:
uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

SecurityException on AccountManager.addAccountExplicitly() for shared android module

I've been following Android's Creating a Sync Adapter (BasicSyncAdapter) to start out my own sync service logic.
The problem: Upon invoking AccountManager.addAccountExplicitly(), a SecurityException is raised, claiming a mismatch between caller and authenticator UID's:
java.lang.SecurityException: caller uid 10048 is different than the authenticator's uid
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.accounts.IAccountManager$Stub$Proxy.addAccount(IAccountManager.java:580)
at android.accounts.AccountManager.addAccountExplicitly(AccountManager.java:565)
App / Library Structure: My app is divided into two modules (gradle / android studio projects):
Android Library (com.example.mylib), which contains the sources and xml's necessary for defining a sync service, adapter, authenticator, etc.
Android Application: to test/demo the library functionality (com.example.mylib.app).
This seems relevant, since the two apps are of different packages. For this reason I've set up the sharedUserId property in the two project manifests (and according to the packages.xml snippets below, it seems to be set up correctly).
All required permissions seem to be set up correctly (namely: READ_SYNC_SETTINGS, WRITE_SYNC_SETTINGS, AUTHENTICATE_ACCOUNTS, USE_CREDENTIALS, GET_ACCOUNTS and MANAGE_ACCOUNTS).
I've also set explicit values for manifest properties (and not going through #string/... expansions) - see below.
Also tried clean builds, clean installs, restarts, etc.
Tech details / dumps follow.
Environment / Setup
Using Android Studio (version 1.3)
targetSdkVersion is 22 (for both projects)
Running on an emulator (genymotion)
System logcat dumps
Following the advice mentioned in this question, I've checked Android System Logcat's seem to be alright as well (until the exception is encountered):
Before (clean installation):
08-10 10:43:39.375 9015-9031/system_process D/PackageManager﹕ New package installed in /data/app/example.mylib.app-1.apk
08-10 10:43:39.387 9015-9027/system_process D/PackageManager﹕ generateServicesMap(android.accounts.AccountAuthenticator): 3 services unchanged
08-10 10:43:39.387 9015-9027/system_process D/PackageManager﹕ generateServicesMap(android.content.SyncAdapter): 6 services:
New service added: ServiceInfo: SyncAdapterType {name=com.example.mylib.provider, type=com.example.mylib.provider.ACCOUNT, userVisible=false, supportsUploading=false, isAlwaysSyncable=true, allowParallelSyncs=false, settingsActivity=null}, ComponentInfo{com.example.mylib.app/com.example.mylib.service.SyncService}, uid 10048
08-10 10:43:39.739 9015-9015/system_process I/ActivityManager﹕ START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.mylib.app/.MyActivity u=0} from pid 19237
08-10 10:43:39.791 9015-9025/system_process I/ActivityManager﹕ Start proc com.example.mylib.app for activity com.example.mylib.app/.MyActivity: pid=19247 uid=10048 gids={3003, 1028}
After stepping through addAccountExplicitly():
08-10 10:45:56.479 9015-9270/system_process V/AccountManagerService﹕ addAccount: Account {name=100, type=com.example.mylib.provider.ACCOUNT}, caller's uid 10048, pid 19247
08-10 10:45:56.479 9015-9270/system_process V/AccountManagerService﹕ caller uid 10048 has android.permission.AUTHENTICATE_ACCOUNTS
08-10 10:45:56.479 9015-9270/system_process W/AccountManagerService﹕ caller uid 10048 is different than the authenticator's uid
Packages Dump
The interesting snippets from /data/system/packages.xml seem to be alright:
...
<package name="com.example.mylib.app"
codePath="/data/app/com.example.mylib.app-1.apk"
nativeLibraryPath="/data/data/com.example.mylib.app/lib"
flags="0" ft="14f170308d8" it="14f16d8b51b" ut="14f17030a42" version="1"
sharedUserId="10048">
<sigs count="1">
<cert index="4" />
</sigs>
<perms />
</package>
...
<shared-user name="com.example.mylib" userId="10048">
<sigs count="1">
<cert index="4" />
</sigs>
<perms>
<item name="android.permission.READ_SYNC_SETTINGS" />
<item name="android.permission.MANAGE_ACCOUNTS" />
<item name="android.permission.USE_CREDENTIALS" />
<item name="android.permission.WRITE_SYNC_SETTINGS" />
<item name="android.permission.GET_ACCOUNTS" />
<item name="android.permission.INTERNET" />
<item name="android.permission.AUTHENTICATE_ACCOUNTS" />
</perms>
</shared-user>
Project Manifests
Library project's mylib_authenticator.xml:
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:sharedUserId="com.example.mylib"
android:accountType="com.example.mylib.provider.ACCOUNT"
android:exported="true"
android:label="#string/service_name"/>
Library project's mylib_syncadapter.xml:
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:sharedUserId="com.example.mylib"
android:contentAuthority="com.example.mylib.provider"
android:accountType="com.example.mylib.provider.ACCOUNT"
android:userVisible="false"
android:exported="true"
android:supportsUploading="false"
android:allowParallelSyncs="false"
android:isAlwaysSyncable="true"
/>
Interesting bits from the library project's AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mylib"
android:sharedUserId="com.example.mylib">
<application>
<provider
android:name="com.example.mylib.provider.MyContentProvider"
android:authorities="com.example.mylib.provider"
android:exported="true"
android:syncable="true"/>
<service
android:name="com.example.mylib.service.SyncService"
android:exported="true"
android:process=":sync">
<intent-filter>
<action android:name="android.content.SyncAdapter"/>
</intent-filter>
<meta-data android:name="android.content.SyncAdapter"
android:resource="#xml/mylib_syncadapter" />
</service>
<service android:name="com.example.mylib.service.AccountService"
android:exported="true">
<intent-filter>
<action android:name="android.content.AccountAuthenticator"/>
</intent-filter>
<meta-data android:name="android.content.AccountAuthenticator"
android:resource="#xml/mylib_authenticator" />
</service>
</application>
Interesting bits from app project's AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mylib.app"
android:sharedUserId="com.example.mylib">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<application ...>
<activity ... />
</application>
</manifest>

Why my map app crashes if I set maxSdkVersion in the WRITE_EXTERNAL_STORAGE permission?

I've set my map following the instructions in this link. And set the WRITE_EXTERNAL_STORAGE permission in accordance with the recomended by the Official Android Documentation, that is request this permission only for API level 18 and lower. So, I have this manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".activities.HomeActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</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="#string/map_api_key"/>
</application>
</manifest>
But I am facing this error:
Caused by: java.lang.SecurityException: The Maps API requires the additional following
permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
But, as it is showed in my manifest, I have this permission. One detail is if I put only the WRITE_EXTERNAL_STORAGE permission, without specifying the maxSdkVersion value, the app works properly.
Is this an Android bug or am I forgetting something in my app configuration?
UPDATE 1
This is the logcat:
FATAL EXCEPTION: main
Process: com.example.map, PID: 15534
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.map/com.example.map.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
at android.app.Activity.setContentView(Activity.java:1929)
at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:216)
at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
at com.example.map.MainActivity.onCreate(MainActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
at maps.e.ci.a(Unknown Source)
at maps.e.ay.a(Unknown Source)
at maps.e.ay.a(Unknown Source)
at maps.e.al.a(Unknown Source)
at maps.e.bh.a(Unknown Source)
at maps.e.bg.a(Unknown Source)
at etu.onTransact(SourceFile:107)
at android.os.Binder.transact(Binder.java:361)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
at com.google.android.gms.dynamic.a$4.b(Unknown Source)
at com.google.android.gms.dynamic.a.a(Unknown Source)
at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1093)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1195)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
UPDATE 2
My layout:
<fragment
android:id="#+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
class="com.google.android.gms.maps.SupportMapFragment" />
UPDATE 3
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
If you check the link you've provided to the <uses-permission> documentation, you'll see that it states that:
it's no longer necessary for your app to request the WRITE_EXTERNAL_STORAGE permission when your app wants to write to its own application-specific directories on external storage (the directories provided by getExternalFilesDir()).
It would appear that the Maps API needs write access to other directories. And if you check the Specify permissions section of the other link you gave, it still lists the WRITE_EXTERNAL_STORAGE permission as required, with no mention of exception for API Level 19.
After having checked many, many online resources with regard to the Maps API, Android API Level 19, and the restriction of the WRITE_EXTERNAL_STORAGE permission, I found no source or example that listed or referenced a working example using the Maps API with that permission restricted to API Level 18 and below. Again, I quote the link you've provided that says the permission is not needed in API Level 19 "when your app wants to write to its own application-specific directories on external storage". (I would point out that it merely says it is not necessary in that case, and in no way "recommends" that you set this restriction absolutely.) The Maps API needs write-permission to external storage directories that are not owned by your app. The fact that "without specifying the maxSdkVersion value, the app works properly" indicates that even in KitKat, Maps needs that permission. The error is telling you exactly that.
I did some research around the maxSdkVersion. And I found the following
From google
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
Warning: Declaring this attribute is not recommended. First, there is no need to set the attribute as means of blocking deployment of your application onto new versions of the Android platform as they are released. By design, new versions of the platform are fully backward-compatible. Your application should work properly on new versions, provided it uses only standard APIs and follows development best practices. Second, note that in some cases, declaring the attribute can result in your application being removed from users' devices after a system update to a higher API Level. Most devices on which your application is likely to be installed will receive periodic system updates over the air, so you should consider their effect on your application before setting this attribute.
I have something like this in my current working google app
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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-feature
android:glEsVersion="0x00020000"
android:required="true" />
So if you really want, you can try put that maxSdkVersion in the note, unless its what google is documented in the above link.
Hope this help
The XML code provided in the link is for Android API 12 or later.
Since your minSDKVersion is 8. Use this:
<fragment
android:id="#+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
class="com.google.android.gms.maps.SupportMapFragment" />
Check here for more.

PhoneGap APK runs fine but crashes on each run after Google Play deployment

I have built an application for a large multicultural festival in my city that kicks off on Saturday. I've tweaked a lot of bugs in the iPhone version and we are waiting for Apple to approve it. I have taken that perfected version as the basis for the Android version.
The Android version looks and works great. I can run it on my Samsung Galaxy S II by either "Run as Android Application" in Eclipse or by uploading it to a server and downloading it into the phone. I can also email the app to myself and it works, too. I submitted it to the Google Play store and once it got into the wild (this is advertised on billboards, buses, everywhere) it crashes the minute it is opened.
I'm not really sure how to troubleshoot this when it works fine on the device before publication. I read about how it has to do with the MainActivity activity name, but everything looks like it lines up.
Error 1 [ClassNotFoundException in PathClassLoader.findClass()]:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.honestapi.folk2011/com.honestapi.folk2011.Folklorama}:
java.lang.ClassNotFoundException: com.honestapi.folk2011.Folklorama in loader
dalvik.system.PathClassLoader[/data/app/com.honestapi.folk2011-1.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:126)
at android.app.ActivityThread.main(ActivityThread.java:3997)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.honestapi.folk2011.Folklorama in loader dalvik.system.PathClassLoader[/data/app/com.honestapi.folk2011-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
at java.lang.ClassLoader.loadClass(ClassLoader.java:548)
at java.lang.ClassLoader.loadClass(ClassLoader.java:508)
at android.app.Instrumentation.newActivity(Instrumentation.java:1022)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
Error 2 [ClassNotFoundException in BaseDexClassLoader.findClass()]:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.honestapi.folk2011/com.honestapi.folk2011.Folklorama}:
java.lang.ClassNotFoundException: com.honestapi.folk2011.Folklorama
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1894)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
at android.app.ActivityThread.access$600(ActivityThread.java:128)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4514)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.honestapi.folk2011.Folklorama
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1027)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1885)
Any help would be greatly appreciated! I am in quite the pickle.
Edit - Here is the AndroidManifest.xml from the bin folder
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="false" android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<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" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.CAMERA" />
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name" android:theme="#style/AppTheme">
<activity android:name=".MainActivity" android:label="#string/title_activity_main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:theme="#android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="#string/share_name">
<intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.ENCODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
It turned out my main Java file was named "MainActivity.java" but it was being called as "Folklorama.java" throughout the project files. I renamed the file to Folklorama.java.

Categories

Resources