I have an app that I put in package/app/myappfolder, I use a library android-support-v4.jar from google, and it is in myappfolder/libs, in Android.mk file I add below lines:
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := android-support-v4:libs/android-support-v4.jar
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
and my code has using android.support.v4.app.* package.
then, I build using "mmm -b packages/app/myappfolder", it gives out build message, it contains below lines
Install: out/target/product/target/system/app/myapp.apk
target Prebuilt: android-support-v4 (out/target/product/target/obj/JAVA_LIBRARIES/android-support-v4_intermediates/javalib.jar)
I thought, it means that build has generated myapp.apk and javalib.jar, the javalib.jar has the library the same as android-support-v4.jar, right?
I just know adb install -r myapp.apk to my target board, and the app can't run, and crashs with errors:
E/AndroidRuntime(24403): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020000 a=-1 r=0x7f020000}
E/AndroidRuntime(24403): at android.content.res.Resources.loadDrawable(Resources.java:1927)
E/AndroidRuntime(24403): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
E/AndroidRuntime(24403): at android.view.View.<init>(View.java:3330)
E/AndroidRuntime(24403): at android.view.ViewGroup.<init>(ViewGroup.java:431)
E/AndroidRuntime(24403): at android.widget.FrameLayout.<init>(FrameLayout.java:101)
E/AndroidRuntime(24403): at android.widget.FrameLayout.<init>(FrameLayout.java:97)
E/AndroidRuntime(24403): ... 28 more
E/AndroidRuntime(24422): FATAL EXCEPTION: main
E/AndroidRuntime(24422): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.changhong.factorymode/com.changhong.factorymode.MainActivity}: android.view.InflateException: Binary XML file line #20: Error inflating class <unknown>
And this app is run well if using eclipse with ADT build and install, Is it the reason that I don't push the javalib.jar to my target board? if so, how to do this? and has any other reason?
Related
I want to import below libraries in my Android Studio Project these are placed in /system/lib64/ folder.
I am getting below error
2020-01-06 13:23:31.358 5171-5171/org.strongswan.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.strongswan.android, PID: 5171
java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib64/libstrongswan.so" needed or dlopened by "/system/lib64/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
at java.lang.System.loadLibrary(System.java:1669)
at org.strongswan.android.logic.CharonVpnService.<init>(CharonVpnService.java:730)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:103)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3740)
at android.app.ActivityThread.access$1400(ActivityThread.java:238)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1803)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7073)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
on the line System.loadLibrary("strongswan")
System.loadLibrary("strongswan");
if (MainActivity.USE_BYOD)
{
System.loadLibrary("tncif");
System.loadLibrary("tnccs");
System.loadLibrary("imcv");
}
System.loadLibrary("hydra");
System.loadLibrary("charon");
System.loadLibrary("ipsec");
System.loadLibrary("androidbridge");
}
From Nougat onwards, Android prevents the runtime linkage of private symbols from system libraries (see this blogpost in Android Developers).
You have two options:
Include those libraries in your APK so that you don't need to look for them in /system/lib/; or
Modify your Android ROM so that those libraries are considered public. This can be done by adding those libraries to /system/etc/public.libraries.txt.
I also meet this error.The situation I tested is like this.
I put the so file in the [libs/yourCpuModel(armeabi-v7a)/] directory will be this error.
I put the so file in the [src/jniLibs/youtCpuModel(armeabi-v7a)/] directory will be this error.
But I put the so file in the [src/main/jniLibs/yourCpuModel(armeabi-v7a)/] directory will not.
I don't know why.Maybe you can try it.
Problem
It is working fine when i am building without release option. release option was working fine with android version 7.1.4
What is expected to happen?
it should build successfully
What does actually happen?
cordova build android --release
Information
build gradle file:
https://gist.github.com/indraraj26/a6efaed1135b0e394a23a1b192bc2c0c
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.3.0-5013011-windows Daemon #0: Unexpected error during compile 'D:\client\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png', attempting to stop daemon. FAILED
20 actionable tasks: 1 executed, 19 up-to-date
This should not happen under normal circumstances, please file an issue if it does.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
D:\client>if "1" == "0" goto mainEnd
D:\client>rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
D:\client>rem the _cmd.exe /c_ return code!
D:\client>if not "" == "" exit 1
D:\client>exit /b 1
Command finished with error code 1: D:\client\platforms\android\gradlew cdvBuildRelease,-b,D:\client\platforms\android\build.gradle
D:\client\platforms\android\gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.3.0-5013011-windows Daemon #0: Unexpected error during compile 'D:\client\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png', attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
Picked up _JAVA_OPTIONS: -Xmx512M
Error: D:\client\platforms\android\gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.3.0-5013011-windows Daemon #0: Unexpected error during compile 'D:\client\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png', attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
Picked up _JAVA_OPTIONS: -Xmx512M
at ChildProcess.whenDone (D:\client\node_modules\cordova-common\src\superspawn.js:135:23)
at ChildProcess.emit (events.js:198:13)
at ChildProcess.cp.emit (D:\client\node_modules\cordova-common\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --release --verbose exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Command or Code
Environment, Platform, Device
Version information
ionic info
[WARN] Detected locally installed Ionic CLI, but it's too old--using global CLI.
Ionic:
Ionic CLI : 5.4.4 (C:\Users\HP\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
#ionic/app-scripts : 3.2.2
Cordova:
Cordova CLI : 8.1.2 (cordova-lib#8.1.1)
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-webview 1.2.1, (and 15 other plugins)
Utility:
cordova-res : 0.8.1
native-run : 0.2.9
System:
Android SDK Tools : 26.1.1 (C:\Users\HP\AppData\Local\Android\Sdk)
NodeJS : v10.16.0 (C:\Program Files\nodejs\node.exe)
npm : 6.10.2
OS : Windows 10
with this solution : https://stackoverflow.com/a/50973967/10842900
i am able to build apk but getting this errors
D:\client\platforms\android\app\src\main\res\drawable-land-hdpi\screen.png: Error: The drawable "screen" in drawable-land-hdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-land-ldpi\screen.png: Error: The drawable "screen" in drawable-land-ldpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-land-mdpi\screen.png: Error: The drawable "screen" in drawable-land-mdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-land-xhdpi\screen.png: Error: The drawable "screen" in drawable-land-xhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-land-xxhdpi\screen.png: Error: The drawable "screen" in drawable-land-xxhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png: Error: The drawable "screen" in drawable-land-xxxhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-port-hdpi\screen.png: Error: The drawable "screen" in drawable-port-hdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-port-ldpi\screen.png: Error: The drawable "screen" in drawable-port-ldpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-port-mdpi\screen.png: Error: The drawable "screen" in drawable-port-mdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-port-xhdpi\screen.png: Error: The drawable "screen" in drawable-port-xhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-port-xxhdpi\screen.png: Error: The drawable "screen" in drawable-port-xxhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\client\platforms\android\app\src\main\res\drawable-port-xxxhdpi\screen.png: Error: The drawable "screen" in drawable-port-xxxhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
Explanation for issues of type "MissingDefaultResource":
If a resource is only defined in folders with qualifiers like -land or -en,
and there is no default declaration in the base folder (layout or values
etc), then the app will crash if that resource is accessed on a device
where the device is in a configuration missing the given qualifier.
As a special case, drawables do not have to be specified in the base
folder; if there is a match in a density folder (such as drawable-mdpi)
that image will be used and scaled. Note however that if you only specify
a drawable in a folder like drawable-en-hdpi, the app will crash in
non-English locales.
There may be scenarios where you have a resource, such as a -fr drawable,
which is only referenced from some other resource with the same qualifiers
(such as a -fr style), which itself has safe fallbacks. However, this still
makes it possible for somebody to accidentally reference the drawable and
crash, so it is safer to create a default dummy fallback in the base
folder. Alternatively, you can suppress the issue by adding
tools:ignore="MissingDefaultResource" on the element.
(This scenario frequently happens with string translations, where you might
delete code and the corresponding resources, but forget to delete a
translation. There is a dedicated issue id for that scenario, with the id
ExtraTranslation.)
12 errors, 0 warnings
The reason this is failing is that there was a bug in aapt2's code for crunching (compressing) PNG files. PNG crunching is automatically disabled for debug builds, but turned on for release, that's why you only saw this in your release builds.
This has been fixed now, so just update your android gradle plugin version and you will get the aapt2 with the fix automatically. I'd suggest 3.5 or newer.
I also see you're on windows, so you might run into another issue that's common if you try to update to 3.5. Aapt2 daemons might fail to start - in that case you just need to install the Windows Universal C Runtime Library.
App works in debug mode just fine by running react-native run-android
But, when I try to build in relase mode by running cd android && ./gradlew assembleRelease
it gives me this error:
android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigation_src_views_assets_backicon.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file..
error: failed parsing overlays.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
I tried workarounds like putting android.enableAapt2=false and org.gradle.configureondemand=true in android/gradle.properties
They both helped me create signed apk but app was crashing on start,
I tried to debug that crash by adb logcat and error is:
FATAL EXCEPTION: Thread-139
java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
Please help me out, I cant seem to figure out how to solve this.
if anyone wonders, we ended up downgrading gradle to
classpath 'com.android.tools.build:gradle:2.2.3'
and it worked.
A runtime exception is happening after executing the command
buck install --run demo_app_android following this tutorial and this sample demo
Then, the following is shown in console
Installing apk on emulator-5554 (null).
[-] PROCESSING BUCK FILES...FINISHED 0.0s [100%] 🐌 File removed
[-] DOWNLOADING... (0.00 B/S AVG, TOTAL: 0.00 B, 0 Artifacts)
[-] BUILDING...FINISHED 0.8s [100%] (1/1 JOBS, 1 UPDATED, 0 [0.0%] CACHE MISS)
[+] INSTALLING...2.1s
Successfully ran install apk //android:demo-app on 1 device(s)
Starting activity com.facebook.buck.demo/.App...
Successfully ran start activity on 1 device(s)
Finally, the device shows a message saying Buck Demo App has stopped
The app was successfully installed as I can see it on the apps list but it's not working
Stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.facebook.buck.demo, PID: 7265
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.facebook.buck.demo-1/base.apk"],nativeLibraryDirectories=[/data/app/com.facebook.buck.demo-1/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libjni.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:972)
at java.lang.System.loadLibrary(System.java:1530)
at com.facebook.buck.demo.Hello.<init>(Hello.java:13)
at com.facebook.buck.demo.App.onCreate(App.java:24)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Device specs:
Native Android Emulator (also, ran it into a real device with same result)
Nexus 5 API 24
My computer:
MacBook pro mid 2012
Note: Also, this issue was reported directly to the buck repository but no solution was given yet
Any idea about how to solve it?
Repeating the answer from github:
You need to install Android NDK from here (version 10e) and set ANDROID_NDK_REPOSITORY to the location of the unpacked NDK (see buckconfig section for more info).
For example, if you unpack NDK to ~/tmp/ndk (so that there is a directory ~/tmp/ndk/android-ndk-r10e), you need to set ANDROID_NDK_REPOSITORY to ~/tmp/ndk.
After that delete old cache and rebuild the app:
$ buck kill && rm -rf buck-out
$ buck build demo_app_android
I'm getting the following error:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com..chat/com..login.LoginActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com..login.LoginActivity" on path: DexPathList[[zip file
"/data/app/com..chat-1/base.apk"],nativeLibraryDirectories=[/data/app/com.*.chat-1/lib/arm,
/vendor/lib, /system/lib]]
I have tried everything I could find online without success. The only way I could get around this by this inefficient script I made:
#!/usr/bin/env bash
./gradlew app:clean
./gradlew app:installDebug
./gradlew app:clean
./gradlew app:installDebug
/home/adel/Android/Sdk/platform-tools/adb shell am start -n com.*.chat/com.*.login.LoginActivity
notify-send -i icon.png "gradle task done" "check your phone"
It works, but takes around 7 minutes to get done. Is there a faster, more efficient way of doing this?
Use just this:
./gradlew --offline clean assembleDebug
To send .apk to your device use something like that:
adb install app/build/output/apk/appDebug.apk
Ensure your apk filename and the path are correct.
I have stopped the Instant run from Android studio and its working.
File->Setting->Build->Instant Run->Disble checkbox of Enable instant run to hotswap code/resource changes