0

I'm manually compiling an apk. But there is an error in packaging when using aapt.

Create a simple project in Android Studio. Then use aapt to package his resources。 The command is shown below:

aapt package -f -m -J build -S res -M AndroidManifest.xml 
-I /SDK/platforms/android-28/android.jar

The error output is as follows:

error: resource style/Theme.AppCompat.Light.NoActionBar (aka com.jz.myapplication:style/Theme.AppCompat.Light.NoActionBar) not found.
./res/values/styles.xml:6: error: style attribute 'attr/colorPrimary (aka com.jz.myapplication:attr/colorPrimary)' not found.
./res/values/styles.xml:7: error: style attribute 'attr/colorPrimaryDark (aka com.jz.myapplication:attr/colorPrimaryDark)' not found.
./res/values/styles.xml:8: error: style attribute 'attr/colorAccent (aka com.jz.myapplication:attr/colorAccent)' not found.
error: failed linking references.
Jawad Malik
  • 608
  • 5
  • 21
范明毅
  • 15
  • 7

1 Answers1

1

You are missing resources from the app compat library.

If you're going to use resources from some libraries, you need to include all of the resources from these libraries and their transitive dependencies using the -S flag. You also need to be mindful of the order of these inputs as they will impact the resource overrides at run-time.

If you use the Android Gradle Plugin instead all of this will be done automatically for you.

Izabela Orlowska
  • 7,431
  • 2
  • 20
  • 33
  • Izabela figured it out right, In addition to it, As using Support Libraries as dependency is dificult to do mannually, You can refer to this answer of mine , which describes how can we use android.jar's general theme. By this you will be independent on any support library and you will be able to compile and create dex files and further into apk. Make sure you sign your apk in order to run on Android device. – Rupesh Kumar Jul 22 '19 at 20:56