clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
645 stars 56 forks source link

apkbuilder was removed from the latest Android Build Tools #30

Closed hellonico closed 11 years ago

hellonico commented 11 years ago

I had to move around a few paths on osx, but basically this goes find until generating the apk file.

There is no apkbuilder in recent releases for osx (or is there ?). Unless lein-droid is only windows based. If not, could you point to the sdk version you are using so I can download it ?

Thanks !

hellonico commented 11 years ago

Even on windows, I could not find the apkbuilder script. Any chance you have it, and the apkbuilder.jar that seens to go with it ?

alexander-yakushev commented 11 years ago

Oh boy, seems like they finally removed it. I will fix this as soon as I find how do they create APKs now without apkbuilder.

hellonico commented 11 years ago

Seems they are using ant, nowadays. The build file build.xml contains the way to use the seemingly new apkbuilder task:

        <apkbuilder
                outfolder="${out.absolute.dir}"
                resourcefile="${resource.package.file.name}"
                apkfilepath="${out.packaged.file}"
                debugpackaging="${build.is.packaging.debug}"
                debugsigning="${build.is.signing.debug}"
                verbose="${verbose}"
                hascode="${manifest.hasCode}"
                previousBuildType="${build.last.is.packaging.debug}/${build.last.is.signing.debug}"
                buildType="${build.is.packaging.debug}/${build.is.signing.debug}">
            <dex path="${intermediate.dex.file}"/>
            <sourcefolder path="${source.absolute.dir}"/>
            <jarfile refid="project.all.jars.path" />
            <nativefolder path="${native.libs.absolute.dir}" />
            <nativefolder refid="project.library.native.folder.path" />
            <extra-jars/>
        </apkbuilder>

And the task itself is in a jar file named tools/lib/ant-tasks.jar

ozanmakes commented 11 years ago

The apkbuilder command line tool is deprecated, and is not maintained anymore. It is lacking recent build improvements such as support for Library Projects.

Its source code has been moved into sdklib. It is recommended to directly use the com.android.sdklib.build.ApkBuilder class instead.

ozanmakes commented 11 years ago

Looks like they've also moved some of the tools around and created a new package named "Android SDK Build-tools":

build-tools/
└── 17.0.0
    ├── aapt
    ├── aidl
    ├── dexdump
    ├── dx
    ├── llvm-rs-cc

@hellonico for the moment you can install build-tools component using the sdk manager, link these files to platform-tools and place apkbuilder there as well to get up to speed.

alexander-yakushev commented 11 years ago

OK, looks like I've tackled this. 0.1.0-SNAPSHOT version should work with the latest Android build tools. Please check it out to see if it works.

I ended up using ApkBuilder class from sdklib.jar, which seems to be an exact replacement for deprecated apkbuilder binary. I've yet to figure out what is it about signing an APK when creating (rather than later) or verbose output, but right now it works (for me).

Also I updated lein-droid to use 17th revision of the build tools as @osener mentioned. That means that previous versions won't work now, as some binaries' locations changed.

hellonico commented 11 years ago

Thank you for the fast updates. Just tested "0.1.0-SNAPSHOT" ;)

Two comments:

├── build-tools │   ├── 17.0.0 -> android-4.2.2 │   └── android-4.2.2

Although, good news, the lein droid repl is working fine indeed.

alexander-yakushev commented 11 years ago

Right now I hardcoded the thing, but this one should be figured out automatically rather than be configured. I'm not quite sure what's the rule for naming (I thought it was Build Tool's version, but you have "android-4.2.2"). Strange.

The second one is very unfortunate. I see now myself that some of the projects crash after the update. Could you please describe your situation? Does the app crash or just shows the empty window? Is there anything in adb logcat?

hellonico commented 11 years ago

adb logcat:

I/AppUpgradeReceiver(24377): Notified of app replace. package:test.leindroid.sample#Intent;action=android.intent.action.PACKAGE_REPLACED;launchFlags=0x10000010;component=com.shazam.android/com.shazam.upgrade.AppUpgradeReceiver;B.android.intent.extra.REPLACING=true;i.android.intent.extra.UID=10047;end I/ActivityManager( 648): No longer want jp.co.nttdocomo.lcsappsub (pid 16233): hidden #26 I/ActivityManager( 648): Start proc com.google.android.apps.maps:LocationFriendService for broadcast com.google.android.apps.maps/com.google.googlenav.friend.reporting.LocationReportingIntentReceiver: pid=24398 uid=10073 gids={3003, 1015} D/dalvikvm(24235): GC_CONCURRENT freed 4051K, 31% free 14845K/21507K, paused 2ms+3ms D/ActivityThread(24398): setTargetHeapUtilization:0.25 D/ActivityThread(24398): setTargetHeapIdealFree:8388608 D/ActivityThread(24398): setTargetHeapConcurrentStart:2097152 I/ActivityManager( 648): No longer want com.android.keychain (pid 24139): hidden #26 I/dalvikvm(24422): Turning on JNI app bug workarounds for target SDK version 10... I/ActivityManager( 648): Start proc com.nttdocomo.android.areamail for service com.nttdocomo.android.areamail/.HeadsetPlugObserverService: pid=24422 uid=10030 gids={} D/ActivityThread(24422): setTargetHeapUtilization:0.25 D/ActivityThread(24422): setTargetHeapIdealFree:8388608 D/ActivityThread(24422): setTargetHeapConcurrentStart:2097152 D/dalvikvm(24235): GC_CONCURRENT freed 4786K, 30% free 15135K/21507K, paused 2ms+2ms I/CNE_DEBUG( 648): CNE received action: android.intent.action.BATTERY_CHANGED I/CNE_DEBUG( 648): UpdateBatteryStatus status=2 pluginType=2 level=35 D/dalvikvm(24235): GC_CONCURRENT freed 5495K, 29% free 15412K/21575K, paused 3ms+4ms D/dalvikvm(24235): GC_CONCURRENT freed 6109K, 31% free 15813K/22599K, paused 2ms+3ms I/ActivityManager( 648): No longer want com.android.remotecontrolservice (pid 24166): hidden #26 D/PowerManagerService( 648): acquireWakeLock flags=0x1 tag=AlarmManager D/PowerManagerService( 648): releaseWakeLock flags=0x1 tag=AlarmManager I/dalvikvm(24235): Could not find method android.app.Activity.applyOverrideConfiguration, referenced from method test.leindroid.sample.MainActivity.applyOverrideConfiguration W/dalvikvm(24235): VFY: unable to resolve virtual method 4: Landroid/app/Activity;.applyOverrideConfiguration (Landroid/content/res/Configuration;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0023 I/dalvikvm(24235): Could not find method android.app.Activity.createConfigurationContext, referenced from method test.leindroid.sample.MainActivity.createConfigurationContext W/dalvikvm(24235): VFY: unable to resolve virtual method 18: Landroid/app/Activity;.createConfigurationContext (Landroid/content/res/Configuration;)Landroid/content/Context; D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0026 I/dalvikvm(24235): Could not find method android.app.Activity.createDisplayContext, referenced from method test.leindroid.sample.MainActivity.createDisplayContext W/dalvikvm(24235): VFY: unable to resolve virtual method 19: Landroid/app/Activity;.createDisplayContext (Landroid/view/Display;)Landroid/content/Context; D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0026 I/dalvikvm(24235): Could not find method android.app.Activity.finishAffinity, referenced from method test.leindroid.sample.MainActivity.finishAffinity W/dalvikvm(24235): VFY: unable to resolve virtual method 45: Landroid/app/Activity;.finishAffinity ()V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0020 I/dalvikvm(24235): Could not find method android.app.Activity.getParentActivityIntent, referenced from method test.leindroid.sample.MainActivity.getParentActivityIntent W/dalvikvm(24235): VFY: unable to resolve virtual method 79: Landroid/app/Activity;.getParentActivityIntent ()Landroid/content/Intent; D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0023 I/dalvikvm(24235): Could not find method android.app.Activity.isDestroyed, referenced from method test.leindroid.sample.MainActivity.isDestroyed W/dalvikvm(24235): VFY: unable to resolve virtual method 97: Landroid/app/Activity;.isDestroyed ()Z D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0027 I/dalvikvm(24235): Could not find method android.app.Activity.navigateUpTo, referenced from method test.leindroid.sample.MainActivity.navigateUpTo W/dalvikvm(24235): VFY: unable to resolve virtual method 102: Landroid/app/Activity;.navigateUpTo (Landroid/content/Intent;)Z D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x002a I/dalvikvm(24235): Could not find method android.app.Activity.navigateUpToFromChild, referenced from method test.leindroid.sample.MainActivity.navigateUpToFromChild W/dalvikvm(24235): VFY: unable to resolve virtual method 103: Landroid/app/Activity;.navigateUpToFromChild (Landroid/app/Activity;Landroid/content/Intent;)Z D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x002d W/dalvikvm(24235): VFY: unable to find class referenced in signature (Landroid/app/TaskStackBuilder;) I/dalvikvm(24235): Could not find method android.app.Activity.onCreateNavigateUpTaskStack, referenced from method test.leindroid.sample.MainActivity.onCreateNavigateUpTaskStack W/dalvikvm(24235): VFY: unable to resolve virtual method 121: Landroid/app/Activity;.onCreateNavigateUpTaskStack (Landroid/app/TaskStackBuilder;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0023 I/dalvikvm(24235): Could not find method android.app.Activity.onNavigateUp, referenced from method test.leindroid.sample.MainActivity.onNavigateUp W/dalvikvm(24235): VFY: unable to resolve virtual method 139: Landroid/app/Activity;.onNavigateUp ()Z D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0027 I/dalvikvm(24235): Could not find method android.app.Activity.onNavigateUpFromChild, referenced from method test.leindroid.sample.MainActivity.onNavigateUpFromChild W/dalvikvm(24235): VFY: unable to resolve virtual method 140: Landroid/app/Activity;.onNavigateUpFromChild (Landroid/app/Activity;)Z D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x002a W/dalvikvm(24235): VFY: unable to find class referenced in signature (Landroid/app/TaskStackBuilder;) I/dalvikvm(24235): Could not find method android.app.Activity.onPrepareNavigateUpTaskStack, referenced from method test.leindroid.sample.MainActivity.onPrepareNavigateUpTaskStack W/dalvikvm(24235): VFY: unable to resolve virtual method 150: Landroid/app/Activity;.onPrepareNavigateUpTaskStack (Landroid/app/TaskStackBuilder;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0023 W/dalvikvm(24235): VFY: unable to find class referenced in signature (Landroid/os/UserHandle;) I/dalvikvm(24235): Could not find method android.app.Activity.removeStickyBroadcastAsUser, referenced from method test.leindroid.sample.MainActivity.removeStickyBroadcastAsUser W/dalvikvm(24235): VFY: unable to resolve virtual method 184: Landroid/app/Activity;.removeStickyBroadcastAsUser (Landroid/content/Intent;Landroid/os/UserHandle;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0026 W/dalvikvm(24235): VFY: unable to find class referenced in signature (Landroid/os/UserHandle;) I/dalvikvm(24235): Could not find method android.app.Activity.sendBroadcastAsUser, referenced from method test.leindroid.sample.MainActivity.sendBroadcastAsUser W/dalvikvm(24235): VFY: unable to resolve virtual method 189: Landroid/app/Activity;.sendBroadcastAsUser (Landroid/content/Intent;Landroid/os/UserHandle;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x003c W/dalvikvm(24235): VFY: unable to find class referenced in signature (Landroid/os/UserHandle;) I/dalvikvm(24235): Could not find method android.app.Activity.sendBroadcastAsUser, referenced from method test.leindroid.sample.MainActivity.sendBroadcastAsUser W/dalvikvm(24235): VFY: unable to resolve virtual method 190: Landroid/app/Activity;.sendBroadcastAsUser (Landroid/content/Intent;Landroid/os/UserHandle;Ljava/lang/String;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x003f W/dalvikvm(24235): VFY: unable to find class referenced in signature (Landroid/os/UserHandle;) I/dalvikvm(24235): Could not find method android.app.Activity.sendOrderedBroadcastAsUser, referenced from method test.leindroid.sample.MainActivity.sendOrderedBroadcastAsUser W/dalvikvm(24235): VFY: unable to resolve virtual method 193: Landroid/app/Activity;.sendOrderedBroadcastAsUser (Landroid/content/Intent;Landroid/os/UserHandle;Ljava/lang/String;Landroid/content/BroadcastReceiver;Landroid/os/Handler;ILjava/lang/String;Landroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x75 at 0x0050 W/dalvikvm(24235): VFY: unable to find class referenced in signature (Landroid/os/UserHandle;) I/dalvikvm(24235): Could not find method android.app.Activity.sendStickyBroadcastAsUser, referenced from method test.leindroid.sample.MainActivity.sendStickyBroadcastAsUser W/dalvikvm(24235): VFY: unable to resolve virtual method 195: Landroid/app/Activity;.sendStickyBroadcastAsUser (Landroid/content/Intent;Landroid/os/UserHandle;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0026 W/dalvikvm(24235): VFY: unable to find class referenced in signature (Landroid/os/UserHandle;) I/dalvikvm(24235): Could not find method android.app.Activity.sendStickyOrderedBroadcastAsUser, referenced from method test.leindroid.sample.MainActivity.sendStickyOrderedBroadcastAsUser W/dalvikvm(24235): VFY: unable to resolve virtual method 197: Landroid/app/Activity;.sendStickyOrderedBroadcastAsUser (Landroid/content/Intent;Landroid/os/UserHandle;Landroid/content/BroadcastReceiver;Landroid/os/Handler;ILjava/lang/String;Landroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x75 at 0x0048 I/dalvikvm(24235): Could not find method android.app.Activity.shouldUpRecreateTask, referenced from method test.leindroid.sample.MainActivity.shouldUpRecreateTask W/dalvikvm(24235): VFY: unable to resolve virtual method 211: Landroid/app/Activity;.shouldUpRecreateTask (Landroid/content/Intent;)Z D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x002a I/dalvikvm(24235): Could not find method android.app.Activity.startActivities, referenced from method test.leindroid.sample.MainActivity.startActivities W/dalvikvm(24235): VFY: unable to resolve virtual method 214: Landroid/app/Activity;.startActivities ([Landroid/content/Intent;Landroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x003c I/dalvikvm(24235): Could not find method android.app.Activity.startActivity, referenced from method test.leindroid.sample.MainActivity.startActivity W/dalvikvm(24235): VFY: unable to resolve virtual method 216: Landroid/app/Activity;.startActivity (Landroid/content/Intent;Landroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x003c I/dalvikvm(24235): Could not find method android.app.Activity.startActivityForResult, referenced from method test.leindroid.sample.MainActivity.startActivityForResult W/dalvikvm(24235): VFY: unable to resolve virtual method 218: Landroid/app/Activity;.startActivityForResult (Landroid/content/Intent;ILandroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0043 I/dalvikvm(24235): Could not find method android.app.Activity.startActivityFromChild, referenced from method test.leindroid.sample.MainActivity.startActivityFromChild W/dalvikvm(24235): VFY: unable to resolve virtual method 220: Landroid/app/Activity;.startActivityFromChild (Landroid/app/Activity;Landroid/content/Intent;ILandroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0047 I/dalvikvm(24235): Could not find method android.app.Activity.startActivityFromFragment, referenced from method test.leindroid.sample.MainActivity.startActivityFromFragment W/dalvikvm(24235): VFY: unable to resolve virtual method 222: Landroid/app/Activity;.startActivityFromFragment (Landroid/app/Fragment;Landroid/content/Intent;ILandroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x0047 I/dalvikvm(24235): Could not find method android.app.Activity.startActivityIfNeeded, referenced from method test.leindroid.sample.MainActivity.startActivityIfNeeded W/dalvikvm(24235): VFY: unable to resolve virtual method 224: Landroid/app/Activity;.startActivityIfNeeded (Landroid/content/Intent;ILandroid/os/Bundle;)Z D/dalvikvm(24235): VFY: replacing opcode 0x6f at 0x004a I/dalvikvm(24235): Could not find method android.app.Activity.startIntentSender, referenced from method test.leindroid.sample.MainActivity.startIntentSender W/dalvikvm(24235): VFY: unable to resolve virtual method 227: Landroid/app/Activity;.startIntentSender (Landroid/content/IntentSender;Landroid/content/Intent;IIILandroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x75 at 0x005b I/dalvikvm(24235): Could not find method android.app.Activity.startIntentSenderForResult, referenced from method test.leindroid.sample.MainActivity.startIntentSenderForResult W/dalvikvm(24235): VFY: unable to resolve virtual method 229: Landroid/app/Activity;.startIntentSenderForResult (Landroid/content/IntentSender;ILandroid/content/Intent;IIILandroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x75 at 0x0070 I/dalvikvm(24235): Could not find method android.app.Activity.startIntentSenderFromChild, referenced from method test.leindroid.sample.MainActivity.startIntentSenderFromChild W/dalvikvm(24235): VFY: unable to resolve virtual method 231: Landroid/app/Activity;.startIntentSenderFromChild (Landroid/app/Activity;Landroid/content/IntentSender;ILandroid/content/Intent;IIILandroid/os/Bundle;)V D/dalvikvm(24235): VFY: replacing opcode 0x75 at 0x0078 I/dalvikvm(24235): Could not find method android.app.Activity.startNextMatchingActivity, referenced from method test.leindroid.sample.MainActivity.startNextMatchingActivity W/dalvikvm(24235): VFY: unable to resolve virtual method 234: Landroid/app/Activity;.startNextMatchingActivity (Landroid/content/Intent;Landroid/os/Bundle;)Z

hellonico commented 11 years ago

The app doesn't crash, but as you can see from the logs, the activity is not found and I only see a blank screen and the topbar named from the application.

alexander-yakushev commented 11 years ago

OK, I will take a look in the evening. I'm not yet sure if my problems and what you get are related, but both of them must be resolved.

hellonico commented 11 years ago

I can do as much testing as needed .. please ping me when you are on it.

alexander-yakushev commented 11 years ago

So I found what was the problem I was having - neko 2.0.0-beta2 was compiled with JDK7, which is unsupported by Android (there is only one java file, and it was enough :-/). Now I recompiled it with JDK6 and released as neko 2.0.0-SNAPSHOT, so my project builds well.

Regarding apkbuilder, I'm now quite confident I've done everything correctly. SBT's android plugin guys did just the same, there isn't much room for error.

@hellonico , please make sure you build your project with JDK6 and use 2.0.0-SNAPSHOT neko version (please remove an existing 2.0.0-SNAPSHOT from Maven so it would be fetched again). If the problem you described (no UI loading) persists, please try to build and APK manually using legacy java class. It will look like:

DEBUG=1 lein do droid compile, droid create-dex

Then in the target folder:

java -Xmx128M $java_debug -classpath /path/to/sdk/tools/lib/sdklib.jar com.android.sdklib.build.ApkBuilderMain project-name-debug-unaligned.apk -u -z project-name.ap_ -f classes.dex -rj /path/to/clojure/in/m2/clojure-1.4.0.jar

And after that:

lein do droid sign-apk, droid zipalign-apk, droid deploy

If create-dex prints anything suspicious, put it here.

Thank you for your help.

kenrestivo commented 11 years ago

I saw the same breakage today after updating. Everything worked for me again after using latest snapshot.

alexander-yakushev commented 11 years ago

It's nice to hear that we are approaching the root of the issue. @hellonico , what's your status? Does the bug persist?

hellonico commented 11 years ago

Someone my comment was lost somewhere. I had complete success using the latest snapshot.

I was actually proposing to do a release of both lein-droid and neko at the same time, so that we can give proper version.

Thank you so much for the great and fun work !

alexander-yakushev commented 11 years ago

Great. I'll pack a new version today... Should somehow fix a subfolder of build-tools as well.

alexander-yakushev commented 11 years ago

All right, lein-droid 0.1.0-preview5 and neko 2.0.0-beta3 are both uploaded to Clojars. Together they fix the issues brought up in this bug report, as well as the build-tools subfolder part (so now you can remove the symbolic link). Please, give it a try and say if it works correctly, thank you.

alexander-yakushev commented 11 years ago

@hellonico Can I close this issue now?

alexander-yakushev commented 11 years ago

Since no one complains about APK creation anymore, I close this issue. Appreciations to @hellonico and @osener for their help to solve this.