APK Expansion File Download exception - android

I recently implemented the APK Expansion File code, described in
http://developer.android.com/guide/market/expansion-files.html, into
my app. I updated the manifest, created the Service and Receiver files
and update my main activity onCreate() to conform to the instructions
in the guide.
I created a signed apk of my app, and uploaded it to my Google Play
account, along with the obb file. These were saved as "drafts".
I then used adb to install my signed APK onto my device and ran it and
immediately got the following exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.MyApp}:
android.database.sqlite.SQLiteException: no such table:
MetadataColumns: , while compiling: SELECT APKVERSION,_id,DOWNLOADSTATUS,DOWNLOADFLAGS FROM MetadataColumns LIMIT 1
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 1821)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 1842)
at android.app.ActivityThread.access$1500(ActivityThread.java: 132)
at android.app.ActivityThread $H.handleMessage(ActivityThread.java:1038)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4263)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: no such table:
MetadataColumns: , while compiling: SELECT APKVERSION,_id,DOWNLOADSTATUS,DOWNLOADFLAGS FROM MetadataColumns LIMIT 1
at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java: 92)
at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java: 65)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java: 49)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java: 53)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java: 1438)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java: 1406)
at com.google.android.vending.expansion.downloader.impl.t.<init>(SourceFile: 76)
at com.google.android.vending.expansion.downloader.impl.t.a(SourceFile: 44)
at com.google.android.vending.expansion.downloader.impl.DownloaderService.a(SourceFile: 634)
What is interesting is that if I run my app through the Eclipse
debugger, I can execute the code that caused the exception, and
continue normal processing, getting a message "Download failed because
you may not have purchased this app".
Any idea why, on a signed version, there is an SQLite exception in the
downloader library, specifically DownloadsDB.java?
My Project Build Target is 2.3.3
I have the Google Play License, Downloader and Zip libraries
referenced by my project
And I have the following in my manifest:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" /
<uses-permission android:name="com.android.vending.CHECK_LICENSE" /
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<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" />
<service android:name=".MyAppDownloaderService" />
<receiver android:name=".MyAppAlarmReceiver" />
TIA,
jb

I did not get exactly the same exception but this might be your problem:
http://code.google.com/p/android/issues/detail?id=31663
The code in DownloadsDB.java is a bit sloppy and occurrences of:
if (null != cur && cur.moveToFirst()) { ... }
must be changed to:
if (null != cur) { if (cur.moveToFirst()) { ... } }

Yes but now approach has been changed a bit. each and every application has key,
this error comes basically for few reasons, make sure :
you are logged in from your test acoount into your device.
key are same in your code as well.
you have mentioned the size of expansion file in code correctly in bytes.
after uploading wait for 3-4 hours, then it will start downloading, instantly it does not work.

Related

Various errors moving app to sdcard depending on api level

A user asked me about a crash while using the app on the sd card. My app was not movable to the sdcard so I added to the manifest android:installLocation="auto" and tried to move it to the external memory. Using it on my real device (34 gb/ 47 gb free on internal/external memory) I get the space not sufficient error. I understood that this is a generic error used for other issues so I fired up the emulator and checked the logcat.
Partial manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.user.app"
android:installLocation="auto"
>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.VIBRATE" />
<queries>
<package android:name="org...." />
</queries>
On my device with android 11 I get
D/PackageManager: START MOVE PACKAGE: pkg{com.github.user.app.debug}
volumeUuid{3231-6462}
I/ActivityTaskManager: START u0 {flg=0x24000000 cmp=com.android.settings/.deviceinfo.StorageWizardMoveProgress (has extras)} from uid 1000
D/RestrictionPolicy: isSettingsChangesAllowedAsUser, userId 0 : true
E/LockGuard: Calling thread PackageManager is holding PACKAGES while trying to acquire DPMS
java.lang.RuntimeException: Calling thread PackageManager is holding PACKAGES while trying to acquire DPMS
at com.android.server.LockGuard.doLog(LockGuard.java:179)
at com.android.server.LockGuard.guard(LockGuard.java:166)
at com.android.server.devicepolicy.DevicePolicyManagerService.getLockObject(DevicePolicyManagerService.java:779)
at com.android.server.devicepolicy.DevicePolicyManagerService.packageHasActiveAdmins(DevicePolicyManagerService.java:5158)
at com.android.server.pm.PackageManagerService.isPackageDeviceAdmin(PackageManagerService.java:22599)
at com.android.server.pm.PackageManagerService.isPackageDeviceAdminOnAnyUser(PackageManagerService.java:22572)
at com.android.server.pm.PackageManagerService.movePackageInternal(PackageManagerService.java:28919)
at com.android.server.pm.PackageManagerService.lambda$movePackage$45$PackageManagerService(PackageManagerService.java:28837)
at com.android.server.pm.-$$Lambda$PackageManagerService$fXZo1oAlF-92gGHcSdrHuC0WLPc.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:44)
...
V/PackageManager: Move 6 created Bundle[{android.intent.extra.PACKAGE_NAME=com.github.user.app.debug, android.intent.extra.TITLE=App-dev}]
I/PackageManager: measurePath: /storage/3231-6462
...
V/PackageManager: Move 6 status 53
...
D/PackageManager: result of install: -15{120868786}
V/PackageManager: Move 6 status -6
On an android api 30 emulator
W/PackageManager: Failed to move com.github.user.app.debug
com.android.server.pm.PackageManagerException: Move only supported for modern cluster style installs
at com.android.server.pm.PackageManagerService.movePackageInternal(PackageManagerService.java:23180)
at com.android.server.pm.PackageManagerService.lambda$movePackage$41$PackageManagerService(PackageManagerService.java:23125)
at com.android.server.pm.-$$Lambda$PackageManagerService$ECakc05vOVsUm8ydpi2Z-HghH4w.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:44)
This is the interested part in PackageManager:
final File probe = new File(pkg.codePath);
final File probeOat = new File(probe, "oat");
if (!probe.isDirectory() || !probeOat.isDirectory()) {
throw new PackageManagerException(MOVE_FAILED_INTERNAL_ERROR,
"Move only supported for modern cluster style installs");
}
I tried again on a fresh api 25 emulator and I get the same error, different exception:
W/installd: type=1400 audit(0.0:879): avc: denied { sys_admin } for capability=21 scontext=u:r:installd:s0 tcontext=u:r:installd:s0 tclass=capability permissive=0
D/installd: Detected label change from u:object_r:system_data_file:s0 to u:object_r:app_data_file:s0:c512,c768 at /mnt/expand/2e6f3762-8f82-4c9f-9633-f74b10070b25/user/0/com.github. user.app.debug; running recursive restorecon
D/installd: Detected label change from u:object_r:system_data_file:s0 to u:object_r:app_data_file:s0:c512,c768 at /mnt/expand/2e6f3762-8f82-4c9f-9633-f74b10070b25/user_de/0/com.github. user.app.debug; running recursive restorecon
D/installd: Copying /data/user_de/0/com.github. user.app.debug to /mnt/expand/2e6f3762-8f82-4c9f-9633-f74b10070b25/user_de/0
D/installd: Copying /data/data/com.github. user.app.debug to /mnt/expand/2e6f3762-8f82-4c9f-9633-f74b10070b25/user/0
W/PackageParser: Unknown element under <manifest>: queries at /mnt/expand/2e6f3762-8f82-4c9f-9633-f74b10070b25/app/com.github.user.app.debug-1/base.apk Binary XML file line #18
W/PackageManager: installPackageLI
D/PackageManager: Cleaning up com.github.user.app.debug on 2e6f3762-8f82-4c9f-9633-f74b10070b25
V/PackageManager: Move 0 status -6
D/StorageSettings: Finished with status -6
W/ActivityManager: Duplicate finish request
I tried to upload an apk instead of letting Android Studio do it but it did not work. Googling the errors only brought me to the soure code links. Any help is appreciated.
I experienced the same issue on an APK installed from Android Studio. Switching between debug and release did not make a difference.
My goal was to install the app onto external to test it, which I was finally able to do under Run/Debug Configurations > Installation Options > Install Flags by adding --install-location 2

Error -505 INSTALL_FAILED_DUPLICATE_PERMISSION:

I am working on a android VOIP Dialer. I unable to install my current app along with old app in a device.
01-07 12:05:05.115: E/Finsky(28214): [1] PackageInstallerImpl$2.onReceive: Error -505 while installing com.current.app: INSTALL_FAILED_DUPLICATE_PERMISSION: Package com.current.app attempting to redeclare permission android.permission.CONFIGURE_SIP already owned by com.old.app
the permission in manifest.
<permission
android:name="android.permission.CONFIGURE_SIP"
android:permissionGroup="android.permission-group.COST_MONEY"
android:protectionLevel="signature" />
I have tried protectionLevel both signature and dangerous.
How can I solve this issue.
It seems you are trying to declare same permission in two applications.
In order to keep both application installed, common solution for this problem is to use a dynamic prefix for your permission, preventing conflicts with other apps (as it happens for GCM configuration too):
<permission
android:name="${applicationId}.permission.CONFIGURE_SIP"
android:permissionGroup="${applicationId}.permission-group.COST_MONEY"
android:protectionLevel="signature" />
Be careful to have applicationId value assigned in your Gradle configuration under android > defaultConfig.

Android Security Exception

I have been struggling with an issue for a while now and decided to post it here in the hope that someone can guide me in the right direction.
Situation
I have two separate applications:
Alpha (com.droidbender.alpha)
Beta (com.droidbender.beta)
Application Beta use an external advertisement SDK (provider Yume). This is a simple .jar library included in the building path and is located ./libs/YumeSDK.jar.
Occuring error
Several cases of a Security Exception have been reported on the PlayStore for the application Alpha
java.lang.SecurityException: Not allowed to start service Intent {
cmp=com.droidbender.beta/com.yume.android.bsp.YuMeUUIDService }
without permission not exported from uid 10041
The complete stack trace can be found below. It goes to the Yume SDK. The Yume SDK is not public and proguarded.
Problem
As you can see, the component name of the Intent that is fired from Alpha is actually targetting Beta.
Alpha does NOT have the Yume SDK implemented, has not included it in the project or isn't referencing to a Yume-related project whatsoever.
Question
I honestly have no idea why application Alpha fires the above Intent. The most answered I found which are related to Security were solved with the android:exported parameter but this didn't fix my issue. Does anyone have an idea? :)
Clean and Build does not help, in case you wondered.
My Thoughts
Application Alpha used to have the Yume SDK implemented but I took it out. I am 100% sure that there is nothing in code related to Yume anymore. Could it be that Eclipse magically keeps a reference to something magical in the magical building process?
Extra information
In the Manifest.xml of Beta we have the declaration of the Yume Service that listens to the appropriate action. This Service is started from inside the Yume SDK.
<service
android:name="com.yume.android.bsp.YuMeUUIDService"
android:exported="true" >
<intent-filter>
<action android:name="com.yume.uuid.GETDEVICEUUID" />
</intent-filter>
</service>
Full stacktrace of the Security Exception shown by application Alpha:
java.lang.SecurityException: Not allowed to start service Intent {
cmp=com.droidbender.beta/com.yume.android.bsp.YuMeUUIDService } without permission not exported from uid 10041
at android.app.ContextImpl.startServiceAsUser(ContextImpl.java:1443)
at android.app.ContextImpl.startService(ContextImpl.java:1425)
at android.content.ContextWrapper.startService(ContextWrapper.java:450)
at com.yume.android.bsp.r.e(Unknown Source)
at com.yume.android.bsp.r.onServiceConnected(Unknown Source)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1131)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1148)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5299)
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:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)

usingOAuth2 deprecated?

I've been working on an Android App that uses Google Drive API. It was originally build from the quickstart example here. The simplified sequence of API calls (with proper error handling not shown here) is:
GoogleAccountCredential cred = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE_FILE);
cred.setSelectedAccountName("...");
Drive drvSvc = new Drive.Builder (AndroidHttp.newCompatibleTransport(), new GsonFactory(), cred).build();
FileList gooLst = drvSvc.files().list().setMaxResults(MAX_DOWN).setQ(_rqst).execute();
It has been working fine and I am just about to release my App. But suddenly, after Drive API update, I'm getting a warning
The method usingOAuth2(Context, String, String...) from the type
GoogleAccountCredential is deprecated
What's happening? Is there another way to obtain credentials? Is there an edited version of quickstart example available anywhere?
Thanks in advance for any clarification. sean
So, the simple answer to my own question is
replace:
GoogleAccountCredential crd =
GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE_FILE);
with
GoogleAccountCredential crd =
GoogleAccountCredential.usingOAuth2(this,
Arrays.asList(DriveScopes.DRIVE_FILE));
For completeness
I'm guessing you got to this exception by following the code example from Google Drive QuickStart. If so you'll might find the following things I had to modify interesting.
Google Play Services Lib (NB. See comment below!)
The documentation uses the old way of adding libraries to an Android project. This will fail when executed with the latest ADT. You will be able to compile and upload to the device/emulator but on execution you'll get a NoClassDefFoundError.
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/AccountPicker;
To fix this you should copy paste the google-play-services.jar file to the libs folder instead.
Missing meta-tag
Up to the next error. I then received an IllegalStateException with the instructions to add a meta-tag in the manifest holding the google-play-services version.
So within the application tag of the manifest add:
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version"/>
And in one of the resource files (res/values/a-file-here.xml) add the following:
<integer name="google_play_services_version">4030500</integer>
In my case the lib matched this version. If you enter the wrong version here you'll get an error showing the proper version to specify. So make sure to check output.
Permission Denied
Finally I got a prompt for oauth in the app just to find out the example app is still missing a permission. The error for reference:
java.io.FileNotFoundException: /storage/emulated/0/Pictures/IMG_20131211_110629.jpg: open failed: EACCES (Permission denied)
Next to the permissions listed within the example:
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
Also add the WRITE_EXTERNAL_STORAGE permission in your manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
More resources
If you get an com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException exception with in the root cause somewhere a description Unknown you should check the settings in the Google API console. I received this error on a package mismatch.
Another links of interest are the oauth2 documentation and the google api playground.

java.lang.NoClassDefFoundError for FragmentActivity class when running Robotium

I've tried everything I could think of, but still I cannot run my tests using Robotium.
I set the robotium library and my main project to be exported in the Project configuration as suggested here
I've set the android:debuggable flag to true as suggested here
I also checked the android:targetPackage is set properly in the manifest as suggested here
Also tried to change the scope of the main project dependency when building the test module to Provided instead of Compile (I am not sure what that does...)
Here is the AndroidManifest for the Test project:
<?xml version="1.0" encoding="utf-8"?>
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.matthieu.tests"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="17" />
<application
android:debuggable="true">
<uses-library android:name="android.test.runner"/>
</application>
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.matthieu"
android:label="Tests for com.matthieu"/>
</manifest>
And here is the exception I get:
java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:239)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
Caused by: java.lang.reflect.InvocationTargetException
at com.matthieu.MainMenuActivityTest.<init>(MainMenuActivityTest.java:26)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87)
at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73)
at android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:263)
at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:185)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:373)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4218)
at android.app.ActivityThread.access$3000(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.matthieu.MainMenuActivity
... 19 more
Note also that I see a few errors like this in the logcat:
01-04 14:44:51.822: WARN/dalvikvm(1263): Class resolved by unexpected DEX: Lcom/matthieu/MainMenuActivity;(0x44e7f980):0x249f70 ref [Lcom/actionbarsherlock/app/SherlockFragmentActivity;] Lcom/actionbarsherlock/app/SherlockFragmentActivity;(0x44e7f980):0x121770
01-04 14:44:51.833: WARN/dalvikvm(1263): (Lcom/matthieu/MainMenuActivity; had used a different Lcom/actionbarsherlock/app/SherlockFragmentActivity; during pre-verification)
01-04 14:44:51.851: WARN/dalvikvm(1263): Unable to resolve superclass of Lcom/matthieu/MainMenuActivity; (644)
01-04 14:44:51.851: WARN/dalvikvm(1263): Link of class 'Lcom/matthieu/MainMenuActivity;' failed
01-04 14:44:51.851: ERROR/dalvikvm(1263): Could not find class 'com.matthieu.MainMenuActivity', referenced from method com.matthieu.MainMenuActivityTest.testFirstTimeAppOpening
01-04 14:44:51.851: WARN/dalvikvm(1263): VFY: unable to resolve check-cast 849 (Lcom/matthieu/MainMenuActivity;) in Lcom/matthieu/MainMenuActivityTest;
If it makes any difference, I am using IntelliJ Idea (11.1.5), SDK 17, SDK Tools 21.0.1 and updated Robotium to 3.6
UPDATE:
Found one related discussion here. I can see different error messages whether I run only one test or all the tests, and my application does use FragmentActivity. But no matter what I do, I am not able to run any test (not one, not all)...
This type of errors occured when you did the below things.
1.If you entered wrong package name for "android:targetPackage" in manifest file.
so please check the target package name in the manifest file.
2.If you add the same library for both android app and test project.
Ambiguity occurs when you add same library for both android app and test project.so please add the library to app project only.
Finally.... I found the only way I could find to make it work there
Do not keep the Robotium test cases in a separate module... no idea why there is no way to make it work, but really I tried everything I could think of or I could find around.
I had this problem for a while and tried many things, what worked for me in the end was simply going into
properties -> Java build path -> Projects
for the test project and then removing the project under test and adding it again. (Since i cannot reproduce the problem and don't remember the details, it may be safest to remove the project under test, then clean both project, and then add the project under test)
I experienced the same problem again (see my other answer on this page) but could not solve the problem with my own solution this time. This time i found another solution: Removing the private libraries for the test project by right clicking on the test project and then
properties -> Java build path -> Libraries
and removing "Android Private Libraries"
PS My answer was inspired by information i found on this page: http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17
I face same problem. its happen just because of i was trying to test my project with the JUnit instead of Android JUnit test.
so for that make test project right click on it > run as > Android Junit test.
it has work in my case.
best of luck

Categories

Resources