What is minimally required to generate an .apk?

42 views
Skip to first unread message

Phil Dougherty

unread,
Aug 12, 2020, 6:09:37 PM8/12/20
to android-ndk
My situation is that I'm attempting to build a vulkan + openxr app for the Oculus Quest.

I've thus far successfully generated my libmyapp.so making use of android_native_app_glue (along with vulkan and oculus' version of openxr).

I have an AndroidManifest.xml which uses <application ... android:hasCode="false">, and the <activity> tag contains <meta-data android:name="android.app.lib_name" android:value="myapp"/> (along with the other recommendations here: https://developer.android.com/ndk/samples/sample_na , and here https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/  ).

I have a build.gradle file which looks like the following:

android {
  compileSdkVersion 30
  buildToolsVersion "30.0.0"
  project.archivesBaseName = "myapp"
  ndkVersion "21.3.6528147"

  defaultConfig {
    applicationId "com.dophil.myapp"
    minSdkVersion 26
    targetSdkVersion 26
    compileSdkVersion 26
    versionCode 1
    versionName "0.1"
  }

  sourceSets {
    main {
      manifest.srcFile 'AndroidManifest.xml'
    }
  }
}

and can run `gradle build` with success (it even generates an .apk).

However- I'm quite sure that I'm missing at LEAST one step (and likely many), because I haven't made explicit where libmyapp.so exists such that it could package it in the .apk (let alone the other resources libmyapp.so expects to be able to find).

what are my next steps in packaging that library, and other resources it needs, together into a coherent .apk? (If this is too large a question, I would also appreciate being directed to some resource which I could use to help myself!) I would prefer if possible to NOT rely on using android studio to create a new project and porting my existing project structure to that (I already have compiled my NDK-using C++ codebase!).

Dan Albert

unread,
Aug 12, 2020, 8:23:30 PM8/12/20
to android-ndk
Preferably you'd use Gradle to build your C++ code (via CMake or ndk-build, using externalNativeBuild), and then you don't have to do anything else.

If for some reason that's a bad fit for your project (it almost never is for anything but third-party code), you can include your libraries as a prebuilt in your project by putting them in the right directory.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/87cb71da-7102-4dae-85b2-eb9376b97aedn%40googlegroups.com.

Phil Dougherty

unread,
Aug 12, 2020, 8:47:38 PM8/12/20
to android-ndk
ah- brilliant! yes that is _exactly_ the doc I was looking for, but my apparently lackluster google fu convinced me didn't exist. thank you!
Reply all
Reply to author
Forward
0 new messages