My app crashed when it comes to sync ExoPlayer library. At first, it crashes when I had Android Studio 3.6 and for no reason it gave me following errors:
enter image description here
enter image description here
but recently I updated Android Studio to 4.0 so I can sync ExoPlayer libraries and no problem when running app
implementation 'com.google.android.exoplayer:exoplayer-core:2.11.4'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.11.4'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.11.4'
but when I add XML code as you see in the following
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id="#+id/video_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
and run my app it crashes and gives me the following error:
2020-05-30 12:39:59.271 18182-18182/? E/Zygote: isWhitelistProcess - Process
is Whitelisted
2020-05-30 12:39:59.271 18182-18182/? E/libpersona: scanKnoxPersonas
2020-05-30 12:39:59.271 18182-18182/? E/libpersona: Couldn't open the File -
/data/system/users/0/personalist.xml - No such file or directory
2020-05-30 12:40:00.364 18182-18182/com.example.myapplication A/libc: Fatal
signal 11 (SIGSEGV), code
1, fault addr 0xb5a9f98 in tid 18182 (e.myapplication), pid 18182
(e.myapplication)
Make Sure you are implemented all below steps :
1- Add repositories:
you should add add these repos exactly with writted order. (buld.gradle:project)
repositories {
google()
mavenCentral()
}
2- Add ExoPlayer full module dependency
implementation 'com.google.android.exoplayer:exoplayer:2.11.4'
3- Turn on Java 8 support (buld.gradle - module:app)
android{
...
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
}
Follow up on #Yasin's answer.
With Google's decision to sunset jcenter in 2022, you might run into another problem - that is your current old version of ExoPlayer is only provided on jcenter but not on google. So I would suggest you to migrate to latest version of ExoPlayer, i.e. v15, as soon as possible - which is guaranteed to be found on google.
Related
Note: Error may be different but if you are getting any error when taking android build without any changes in code for past two days
My Error - Failed to install the app. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
error Failed to install the app. Make sure you have the Android development environment set up:
Error: Command failed: ./gradlew app:installDebug
-PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where: Build file '/Users/....../node_modules/react-native-month-year-picker/android/build.gradle' line: 115
* What went wrong: A problem occurred configuring project ':react-native-month-year-picker'.
> Could not resolve all files for configuration ':react-native-month-year-picker:implementation'.
> Could not resolve com.facebook.react:react-native:+.
Required by:
project :react-native-month-year-picker
> Cannot choose between the following variants of com.facebook.react:react-native:0.71.0-rc.0:
- debugVariantDefaultRuntimePublication
- releaseVariantDefaultRuntimePublication
All of them match the consumer attributes:
- Variant 'debugVariantDefaultRuntimePublication' capability com.facebook.react:react-native:0.71.0-rc.0:
The build failures for Android was due to the publish of the React Native version 0.71.0-rc0.
Note: Error may be different but this would be the solution if you are getting android build failures without any changes in code for past two days
before trying these methods please revert back every changes you have done : https://stackoverflow.com/a/74371195/10657559
Method 1
Add this fix to your android -> build.gradle file as follows:
buildscript {
// ...
}
allprojects {
repositories {
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
// ...
}
}
What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules
Method 2
If your gradle doesn't support above, then add this to your android -> build.gradle file as follows:
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
buildscript {
// ...
}
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
// ...
}
Ref: Fix and updates on Android build failures happening since Nov 4th 2022 #35210
Adding on to the voted answer to do some knowledge sharing.
To reiterate, as #Thanhal has posted, the solution and official explanation can be found here: Android build failures No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found.
The biggest question I needed answer following the error was:
After specifying my react-native version in package.json, why does my project still download another react-native version?
I even used npm install --save-exact to ensure I am getting the correct version
The error message I was given left me even more confused:
The class is loaded from ~/.gradle/caches/transforms-3/9a8c596b7e1788d5bad7c80991eefff1/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: .../node_modules/expo-modules-core/android/src/main/java/expo/modules/adapters/react/permissions/PermissionsService.kt: (351, 32): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.1.
Somehow Kotlin became an issue for me as well.
Who / What is asking for the latest react-native?
For my case, the issue here wasn't about the version of react-native my project is using. It was about what my libraries are using.
The react-native team had been shipping a Maven Repository inside the NPM package (node_modules/react-native/android/) up till 0.71.0-rc.0. Most of the libraries have their build.gradle configured to reference to this directory. This is done through declaring a custom repository in the libraries' build.gradle:
maven {
url "$rootDir/../node_modules/react-native/android"
}
But in the libraries' build.gradle files, more repositories are declared, which may look like this:
repositories {
maven {
url "$rootDir/../node_modules/react-native/android"
}
google()
mavenLocal()
mavenCentral()
}
Then, the dependency for the library is declared as so:
dependencies {
implementation 'com.facebook.react:react-native:+'
}
Because the "+" as version for the react-native dependency, Gradle will take the latest react-native version from the various declared repositories.
Since in the past react-native was shipped with npm package, the latest which Gradle will always take the react-native in node_modules. However, now that the react-native team is publishing the library to public repositories including MavenCentral, Gradle honours the "+" and take the version on MavenCentral instead.
Why did I get the Kotlin error?
My project uses an older version of react-native and as of version 0.68 react-native started using Kotlin version 1.6.10 (see the change history). So yes, the difference in react-native version would also result in Kotlin error.
Facebook has release bugfix versions for >=0.63. You can upgrade instead of apply the hotfix also.
https://github.com/facebook/react-native/issues/35210
This fix works:
Reason for Failures : The build failures for Android was due to the publish of the React Native version 0.71.0-rc0 to Maven and because of which when the gradle is syncing its picking this 0.71.0-rc0 version of react-native rather then your current version of react-native.
Made it work without upgrading react-native version and by adding this in build.gradle, this works (hermes enabled or not, along with flipper too)
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
final snippet looks like this
allprojects {
repositories {
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
gradle clean and rebuild after this fix. Then you can react native run android successfully.
What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules
Now,
There are some patch releases from react native for different versions, If you dont want to put this fix,
you can update your current react native version to the react native patch version as mentioned here
https://github.com/facebook/react-native/issues/35210
I created a react-native app and published it yesterday. The app is crashing whenever I try to open it on a real device but is is working in a simulator(using android studio). I collected a user sent crash report it is showing me this error. I am a beginner in android development and I don't know java.
I used android app bundle.
Can anyone help me to diagnose the error and what could I do to get more information regarding this and also how can I fix it.
java.lang.UnsatisfiedLinkError:
at com.facebook.soloader.SoLoader.loadLibraryBySoName (SoLoader.java:314)
at com.facebook.soloader.SoLoader.loadLibrary (SoLoader.java:247)
at com.facebook.react.bridge.ReactBridge.staticInit (ReactBridge.java:18)
at com.facebook.react.bridge.NativeMap.<clinit> (NativeMap.java:19)
at com.facebook.react.bridge.JSCJavaScriptExecutorFactory.create (JSCJavaScriptExecutorFactory.java:21)
at com.facebook.react.ReactInstanceManager$5.run (ReactInstanceManager.java:912)
at java.lang.Thread.run (Thread.java:764)
I solved one issue after adding this into the build.gradle file. But now It is showing me an older version of the app and also dependency graph is not loaded. It is stuck. Help
ndk {
abiFilters "armeabi-v7a", "x86", 'armeabi', 'arm64-v8a'
}
packagingOptions {
exclude "lib/arm64-v8a/libgnustl_shared.so"
exclude '/lib/mips64/**'
exclude '/lib/arm64-v8a/**'
exclude '/lib/x86_64/**'
}
You have to upgrade the react-native version to 0.59 for supporting 64-bit native libs. http://facebook.github.io/react-native/blog/2019/03/12/releasing-react-native-059
I am fetching Google advertising id in my application, I have updated my android studio and android SDK.
minSdkVersion 15
targetSdkVersion 27
Current gradle version is : 3.1.3
Google services is : 3.0.0
Google Play Services Version : 11.8.0
android Support Libraries Version : 27.1.1
While fetching GAID, I am getting following error
error: package com.google.android.gms.ads.identifier does not exist
Not able to find AdvertisingIdClient class.
I am bit stuck here, Please help me.
Thank you.
The solution here worked for me
https://www.solutionfactory.in/posts/error-package-com-google-android-gms-ads-solved
adding this to my gradle build file particularly solved my problem.
implementation 'com.google.android.gms:play-services-ads:15.0.0'
Seems that google has moved it to ads play services!
You have to add implementation com.google.android.gms:play-services-ads:15.0.1 to your dependencies
I have been trying to add ReactNative to my existing android application. I followed the instructions from this link. I could add it but the app gets crashed once I open the react native activity. I have started server using
adb reverse tcp:8081 tcp:8081
and started react-native using
react-native start
I get a dialogue that the js files are loading. But finally end up with a crash. Following is the error that is being printed in logcat:
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:213)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:178)
at com.facebook.react.bridge.JSCJavaScriptExecutor.<clinit>(JSCJavaScriptExecutor.java:19)
at com.facebook.react.ReactInstanceManager.onJSBundleLoadedFromServer(ReactInstanceManager.java:413)
at com.facebook.react.ReactInstanceManager.createReactContextInBackground(ReactInstanceManager.java:236)
I am completely lost as I am unable to figure out the cause for this issue.
Thanks in advance.
actually in my case these steps worked:
uninstall the app from the device
close Metro Bundler
run ./gradlew clean on android directory
run react-native run-android
hope to help you.
This has fixed my issue :
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
This should be placed build.gradle defaultConfig section.
This is caused by the following issue (open for 2 years) https://github.com/facebook/react-native/issues/2814
From the issue:
React Native on Android doesn't provide a 64-bit version of the libreactnativejni.so native library, which can cause compatibility issues on 64-bit devices. I ran into this while attempting to integrate React Native with a large existing application I'm developing.
Reaction from Facebook:
"Thanks for reporting! Yes we don't provide 64-bit version of the native code and the system should always fall back to 32-bit."
And:
"Most Android projects use a number of 3rd-party libraries, and any that include native 64-bit code will cause React Native to fail."
The following SO answer Use 32-bit jni libraries on 64-bit android explains fallback to 32-bit libraries and the fact you cannot mix. So if 64-bit is found, all should be 64-bit
I suggest reading along the Github issue #2814. There are multiple fixes proposed, but it depends on your situation what works.
The issuer has also written a blog about it: Mixing 32- and 64-bit Dependencies in Android
Hope this helps!
To me what worked was to clean project build and build it again.
Solution 1:
follow these steps:
uninstall the app from the device
close Metro Bundler
run ./gradlew clean on android directory
run react-native run-android
hope to help you.
Solution 2:
you can use the old version of soloader by adding configurations.all into your build.gradle
configurations.all {
resolutionStrategy {
force "com.facebook.soloader:soloader:0.8.2"
}
}
like this
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
configurations.all {
resolutionStrategy {
force "com.facebook.soloader:soloader:0.8.2"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
reference
https://stackoverflow.com/a/61695629/8079868
I solved this issue, update fresco library that is support for app bundle is 2.0.0 below this will not support,
Update: For me the issue got solved after updating fresco to 2.0.0, because 1.11.0 apparently didn't have support for Android App Bundles. I don't know if you all had the same problem, though.
just do this :
implementation 'com.facebook.fresco:fresco:2.0.0'
I had the same issue when running on Android 30. Following addition to the android/build.gradle file worked for me:
configurations.all {
resolutionStrategy {
// use 0.9.0 to fix crash on Android 11
force "com.facebook.soloader:soloader:0.9.0"
}
}
Credits
This worked for me,
cd android
./gradlew clean
It might be lib\x86_64\libreactnativejni.so not found due to missing strip tool for ABI 'X86_64'
Try the following steps.
Uninstall the apk
Clean the android folder
Navigate to android folder cd android.
Clean the directory using
gradle
For Windows, gradlew clean
For Linux, ./graldew clean
Now you can try react-native run-android --no-jetifier
Step 1: Goto Android Studio -> Build -> clean project.
Step 2: delete the project in your device.
Step 3: run react-native start.
Step 4: run npx react-native run-android.
It's working for me, no need of any gradle related changes.
if you are fresco libray then make sure use latest version and set the properties as false :
shrinkResources false
minifyEnabled false
Inside build.gradle file.
I've added a Java Library dependency module to the app module of my project. When I try to run the app I get this error:
...while parsing hai/shoplist/ItemBag.class
1 error; aborting
Error:Execution failed for task ':app:preDexDebug'.com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException: Process 'command 'C:\ProgramFiles\Java\jdk1.8.0_05\bin\java.exe'' finished with non-zero exit value 1
I've tested the classes that I have in the module and I can even build it but the problem arises when I try to run the app.
Android doesn't support Java 8.
Add to your library build.gradle:
sourceCompatibility = 1.7.
It should solve your problem.
Due to Androids design, there is a limitation on how many methods your application may contain. You might have exceeded this amount. To solve this, enabled multidex support as explained here.
More information about it be found in the Android developer docs.