toolchains icon indicating copy to clipboard operation
toolchains copied to clipboard

Unable to import APK through Android Studio

Open hsdk123 opened this issue 5 years ago • 5 comments

I've just managed to get up to apk packaging completing, and now trying to debug, I've initially tried importing the APK through Android Studio (option: Profile or debug APK), but I'm getting errors when selecting the cmake built file:

APK Import
Unable to find file
'Users/hkim809/ApkProjects/MyApplication/small/classes.dex'

Any ideas?

hsdk123 avatar Dec 31 '19 01:12 hsdk123

I took most of the internals from fips, and it seems mirroring this commit would make things work again: https://github.com/floooh/fips/commit/63fdb7a332e17cda2d3435a2dc72829606815db7

Unfortunately right now I'm unable to set up Android build locally (the SSD on this mac mini is too small, heh), so you'd either have to try to tackle this yourself or wait until I have a real computer again (in three weeks, hopefully).

mosra avatar Jan 01 '20 09:01 mosra

Hmm, looks as if those lines are just doing some symbol replacement to get things working 'again'. (implying something was up before and that might just be a bug fix on top)

I've looked around the repo, and it seems there's some core steps run to build the dex: https://github.com/mosra/toolchains/issues/11#issuecomment-570039090

Seems like a src directory is created then somehow a /R.java is pulled in, built, and then a dex created afterwards through a separate command.

I think I can wait 3 weeks, so I might go back to try tackling the iOS build and emscripten build first. Will update though if I dabble into this again, but when that real computer comes in, let me know!

hsdk123 avatar Jan 01 '20 15:01 hsdk123

@hsdk123 were you able to make any progress on this? I'm coming back to this with absolutely no prior knowledge of what the APK should or should not have, so ¯\_(ツ)_/¯

Or did the extra commits in #10 solve this in any way?

mosra avatar Jun 10 '20 16:06 mosra

Actually not really, Android Studio and Gradle were a pain and I couldn't even get things to build.... I did however spend about a week though looking through what should be happening, here are a couple of links I jotted down along the way:

  • Android Studio can't find dex. Reference implementation:
    https://github.com/floooh/fips/blob/master/tools/android-create-apk.py#L142

  • Android apk stucture:
    https://en.wikipedia.org/wiki/Android_application_package

  • Android manifest: https://developer.android.com/guide/topics/manifest/manifest-intro.html

  • Android appt doesn't allow non-ascii filenames to be packaged:
    https://stackoverflow.com/questions/10543713/mono-for-android-unicode-assets-file-names-cant-be-packaged https://elinux.org/Android_aapt

  • Check app2 at some point (might fix non-ascii filename problem)
    https://developer.android.com/studio/command-line/aapt2

  • Android apk building through cmake
    https://github.com/Discordia/android-cmake/blob/master/android.apk.cmake
    https://github.com/Discordia/android-cmake-example/tree/master/android
    https://github.com/PixelLightFoundation/pixellight/blob/master/cmake/Android/Apk.cmake
    https://github.com/hunter-packages/android-apk/blob/master/AndroidApk.cmake
    https://github.com/floooh/fips/blob/master/tools/android-create-apk.py

hsdk123 avatar Jun 11 '20 02:06 hsdk123

Thanks a lot for the links. I can imagine the pain behind, haha :)

mosra avatar Jun 11 '20 09:06 mosra