react-native-detox building on android blocked by proguard - react-native

I've been trying to use detox to test e2e.
RN 0.57.0
I followed the integration steps for android but I'm blocked on trying to compile the project.
detox build -c android.emu.debug
It builds perfectly when I run the normal ./gradlew assembleRelease command.
Note: there were 27 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning: library class android.content.res.XmlResourceParser extends or implements program class org.xmlpull.v1.XmlPullParser
Warning: android.support.test.espresso.core.internal.deps.guava.cache.Striped64: can't find referenced class sun.misc.Unsafe
...
Warning: android.support.test.espresso.core.internal.deps.guava.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning: android.support.test.espresso.core.internal.deps.guava.util.concurrent.AbstractFuture$UnsafeAtomicHelper: can't find referenced class sun.misc.Unsafe
...
Warning: android.support.test.espresso.core.internal.deps.guava.util.concurrent.AbstractFuture$UnsafeAtomicHelper$1: can't find referenced class sun.misc.Unsafe
Warning: library class android.content.Intent depends on program class org.xmlpull.v1.XmlPullParser
Warning: library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlSerializer
Warning: library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlPullParser
Warning: library class android.graphics.drawable.BitmapDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
...
Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlSerializer
Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
Warning: there were 24 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 14 instances of library classes depending on program classes.
You must avoid such dependencies, since the program classes will
be processed, while the library classes will remain unchanged.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForReleaseAndroidTest'.
> Job failed, see logs for details
* 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 1m 30s
child_process.js:644
throw err;
^
Perhaps detox requires another proguard file?
----UPDATE----
Here is my build.gradle dependencies:
dependencies {
compile project(':rn-fetch-blob')
implementation project(':react-native-firebase')
implementation project(':react-native-image-resizer')
implementation project(':react-native-zendesk-support')
implementation project(':bugsnag-react-native')
implementation project(':react-native-fast-image')
implementation project(':react-native-calendar-events')
implementation project(':react-native-contacts')
implementation project(':react-native-device-info')
implementation project(':react-native-image-picker')
implementation project(':react-native-config')
implementation project(':react-native-restart')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.1.0"
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation "com.facebook.react:react-native:+" // From node_modules
// Firebase dependencies
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-analytics:15.0.2"
implementation('com.crashlytics.sdk.android:crashlytics:2.9.3#aar') {
transitive = true;
}
implementation project(':react-native-photo-view')
implementation (project(':react-native-camera')) {
implementation 'com.android.support:exifinterface:27.1.0'
implementation ('com.google.android.gms:play-services-vision:15.0.1') {
force = true
}
}
implementation(project(':react-native-notifications')) {
exclude group: 'com.google.firebase', module: 'firebase-messaging'
}
implementation("com.google.firebase:firebase-messaging:15.0.2") {
implementation project(':react-native-notifications')
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
implementation project(':react-native-code-push')
androidTestImplementation(project(":detox"))
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
}
Not sure if the react native dependencies make a difference...
Perhaps there is a mismatch in versions?

Related

MainApplication.java:9: Error: Packagecom.reactnativecommunity.webview does not exist

% npx react-native run-android Starting JS server... Building and
installing the app on the device (cd android && ./gradlew
installDebug)...
Configure project :react-native-reanimated WARNING: The specified Android SDK Build Tools version (28.0.2) is ignored, as it is below
the minimum supported version (29.0.2) for Android Gradle Plugin
4.1.0. Android SDK Build Tools 29.0.2 will be used. To suppress this warning, remove "buildToolsVersion '28.0.2'" from your build.gradle
file, as each version of the Android Gradle Plugin now has a default
version of the build tools. Warning: Mapping new ns
http://schemas.android.com/repository/android/common/02 to old ns
http://schemas.android.com/repository/android/common/01 Warning:
Mapping new ns
http://schemas.android.com/repository/android/generic/02 to old ns
http://schemas.android.com/repository/android/generic/01 Warning:
Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02
to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns
http://schemas.android.com/sdk/android/repo/repository2/02 to old ns
http://schemas.android.com/sdk/android/repo/repository2/01 Warning:
Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02
to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Configure project :react-native-linear-gradient WARNING: Configuration 'provided' is obsolete and has been replaced with
'compileOnly'. It will be removed in version 5.0 of the Android Gradle
plugin. For more information, see
http://d.android.com/r/tools/update-dependency-configurations.html.
Configure project :react-native-orientation WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and
'api'. It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see
http://d.android.com/r/tools/update-dependency-configurations.html.
Configure project :app WARNING: The option 'android.useDeprecatedNdk' is deprecated. The current default is
'false'. It has been removed from the current version of the Android
Gradle plugin. NdkCompile is no longer supported WARNING:
Configuration 'compile' is obsolete and has been replaced with
'implementation' and 'api'. It will be removed in version 5.0 of the
Android Gradle plugin. For more information, see
http://d.android.com/r/tools/update-dependency-configurations.html.
WARNING: API 'variant.getMergeResources()' is obsolete and has been
replaced with 'variant.getMergeResourcesProvider()'. It will be
removed in version 5.0 of the Android Gradle plugin. For more
information, see
https://d.android.com/r/tools/task-configuration-avoidance. To
determine what is calling variant.getMergeResources(), use
-Pandroid.debug.obsoleteApi=true on the command line to display more information. WARNING: API 'variant.getPackageApplication()' is
obsolete and has been replaced with
'variant.getPackageApplicationProvider()'. It will be removed in
version 5.0 of the Android Gradle plugin. For more information, see
https://d.android.com/r/tools/task-configuration-avoidance. To
determine what is calling variant.getPackageApplication(), use
-Pandroid.debug.obsoleteApi=true on the command line to display more information. WARNING: API 'variant.getMergeAssets()' is obsolete and
has been replaced with 'variant.getMergeAssetsProvider()'. It will be
removed in version 5.0 of the Android Gradle plugin. For more
information, see
https://d.android.com/r/tools/task-configuration-avoidance. To
determine what is calling variant.getMergeAssets(), use
-Pandroid.debug.obsoleteApi=true on the command line to display more information.
Task :app:compileDebugJavaWithJavac FAILED /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:9:
Error: Packagecom.reactnativecommunity.webview does not exist import
com.reactnativecommunity.webview.RNCWebViewPackage;
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:18:
Error: Packagecom.beefe.picker does not exist import
com.beefe.picker.PickerViewPackage;
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:28:
Error: Packagecom.reactnativenavigation does not exist import
com.reactnativenavigation.NavigationApplication;
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:29:
Error: Packagecom.reactnativenavigation.react does not exist import
com.reactnativenavigation.react.NavigationReactNativeHost;
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:30:
Error: Packagecom.reactnativenavigation.react does not exist import
com.reactnativenavigation.react.ReactGateway;
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:36:
Error: Symbol not found public class MainApplication extends
NavigationApplication {
^ シンボル: Class NavigationApplication
/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:45:
Error: Symbol not found
protected ReactGateway createReactGateway() {
^ シンボル: Class ReactGateway 場所: Class MainApplication
/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.java:8:
Error: Packageandroid.support.annotation does not exist import
android.support.annotation.Nullable;
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.java:12:
Error: Packagecom.reactnativenavigation does not exist import
com.reactnativenavigation.NavigationActivity;
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.java:18:
Error: Symbol not found public class MainActivity extends
NavigationActivity {
^ シンボル: Class NavigationActivity /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.java:21:
Error: Symbol not found
protected void onCreate(#Nullable Bundle savedInstanceState) {
^ シンボル: Class Nullable 場所: Class MainActivity
/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:44:
Error: Method does not override super
#Override
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:46:
Error: Symbol not found
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
^ シンボル: Class NavigationReactNativeHost 場所: Class MainApplication
/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:47:
Error: Method does not override super
#Override
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:52:
Error: Symbol not found
return new ReactGateway(this, isDebug(), host);
^ シンボル: Class ReactGateway 場所: Class MainApplication
/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:55:
Error: Method does not override super
#Override
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:68:
Error: Symbol not found
new PickerViewPackage(),
^ シンボル: Class PickerViewPackage 場所: Class MainApplication
/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:70:
Error: Class FBSDKPackageのコンストラクタ FBSDKPackageは指定された型に適用できません。
new FBSDKPackage(mCallbackManager),
^ 期待値: 引数がありません 検出値: CallbackManager 理由: 実引数リストと仮引数リストの長さが異なります
/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:72:
Error: Symbol not found
new RNCWebViewPackage(),
^ シンボル: Class RNCWebViewPackage 場所: Class MainApplication
/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/MainApplication.java:79:
Error: Method does not override super
#Override
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.java:20:
Error: Method does not override super
#Override
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.java:22:
Error: Symbol not found
super.onCreate(savedInstanceState);
^ シンボル: 変数 super 場所: Class MainActivity /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.java:26:
Error: Symbol not found
PackageInfo info = getPackageManager().getPackageInfo(
^ シンボル: メソッド getPackageManager() 場所: Class MainActivity
/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.java:48:
Error: Method does not override super
#Override
^ /Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.java:50:
Error: Symbol not found
super.onActivityResult(requestCode, resultCode, data);
^ シンボル: 変数 super 場所: Class MainActivity ノート:/Users/tenna/Downloads/aitem/android/app/src/main/java/com/aitem/com/aitem/MainActivity.javaは推奨されないAPIを使用またはオーバーライドしています。
ノート:詳細は、-Xlint:deprecationオプションを指定して再コンパイルしてください。 Error25個
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
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
Deprecated Gradle features were used in this build, making it
incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation
warnings and determine if they come from your own scripts or plugins.
See
https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 7s 145 actionable tasks: 2 executed, 143 up-to-date
Could not install the app on the device, read the error above for
details. Make sure you have an Android emulator running or a device
connected and have set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: ./gradlew installDebug
Error: Command failed: ./gradlew installDebug
at checkExecSyncError (node:child_process:707:11)
at Object.execFileSync (node:child_process:726:15)
at runOnAllDevices (/Users/tenna/Downloads/aitem/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
at buildAndRun (/Users/tenna/Downloads/aitem/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
at /Users/tenna/Downloads/aitem/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12
at processTicksAndRejections (node:internal/process/task_queues:96:5)
click on android folder
click on app folder
click on src folder
click on java folder
click on MainApplication.java file and remove Packagecom.reactnativecommunity.webview in line 9
use latest updated one
npm i react-native-webview

Not able to run unit tests on kotlin Multiplatform project

I am trying to create a kotlin Multiplatform library which can later convert into java and javascript using  IDEA 2019.3, kotlin 1.3 .
I created a simple junit (4) test class and configured it as follows.
package sample;
import org.junit.Test;
public class Tests {
#Test
public void test1(){
System.out.println("here");
}
}
But while running, it’s failing with
Process finished with exit code 1 Class not found: "sample.DummyTest"
I could not figure out what am I doing wrong. Please advice.
check your name of class test, it could be: com.package.example.Tests
or click right on your class and make the configuration:
if you want to run all test (included unitest from implements modules) in your project, create this configuration:
in your gradle dependencies check this import
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

react-native-maps build failed

I installed react-native-maps but when i try to build it fails and gives the following error despite that javac works
> Task :react-native-maps:compileDebugJavaWithJavac
D:\COURSES\ReactNative-ThePracticalGuide\myFirstApp\node_modules\react-native-ma
ps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:12: e
rror: package androidx.core.view does not exist
import androidx.core.view.GestureDetectorCompat;
^
D:\COURSES\ReactNative-ThePracticalGuide\myFirstApp\node_modules\react-native-ma
ps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:13: e
rror: package androidx.core.view does not exist
import androidx.core.view.MotionEventCompat;
^
D:\COURSES\ReactNative-ThePracticalGuide\myFirstApp\node_modules\react-native-ma
ps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:73: e
rror: package androidx.core.content does not exist
import static androidx.core.content.PermissionChecker.checkSelfPermission;
^
D:\COURSES\ReactNative-ThePracticalGuide\myFirstApp\node_modules\react-native-ma
ps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:73: e
rror: static import only from classes and interfaces
import static androidx.core.content.PermissionChecker.checkSelfPermission;
^
D:\COURSES\ReactNative-ThePracticalGuide\myFirstApp\node_modules\react-native-ma
ps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:108:
error: cannot find symbol
private final GestureDetectorCompat gestureDetector;
^
symbol: class GestureDetectorCompat
location: class AirMapView
D:\COURSES\ReactNative-ThePracticalGuide\myFirstApp\node_modules\react-native-ma
ps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:165:
error: cannot find symbol
new GestureDetectorCompat(reactContext, new GestureDetector.SimpleOnGest
ureListener() {
^
symbol: class GestureDetectorCompat
location: class AirMapView
D:\COURSES\ReactNative-ThePracticalGuide\myFirstApp\node_modules\react-native-ma
ps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:421:
error: cannot find symbol
return checkSelfPermission(getContext(), PERMISSIONS[0]) == PackageManager.P
ERMISSION_GRANTED ||
^
symbol: method checkSelfPermission(Context,String)
location: class AirMapView
D:\COURSES\ReactNative-ThePracticalGuide\myFirstApp\node_modules\react-native-ma
ps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:422:
error: cannot find symbol
checkSelfPermission(getContext(), PERMISSIONS[1]) == PackageManager.PERM
ISSION_GRANTED;
^
symbol: method checkSelfPermission(Context,String)
location: class AirMapView
D:\COURSES\ReactNative-ThePracticalGuide\myFirstApp\node_modules\react-native-ma
ps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:949:
error: cannot find symbol
int action = MotionEventCompat.getActionMasked(ev);
^
symbol: variable MotionEventCompat
location: class AirMapView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
9 errors
> Task :react-native-maps:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-maps:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
the versions of my packages
"react-native": "0.59.10",
"react-native-maps": "0.26.1",
the dependencies in app/build.gradle file
dependencies {
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation 'com.android.support:design:27.1.0'
implementation "com.facebook.react:react-native:+" // From node_modules
compile fileTree(dir: "libs", include: ["*.jar"])
compile project(':react-native-vector-icons')
compile project(':react-native-navigation')
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:10.0.1'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
}
I followed the installations instructions carefully but the build still failed.
Any solution to this problem ?
try upgrading react native to a version 0.60+ and don't forget to unlink react native maps
I found the solution to my problem.
First i add the following lines to ./android/gradle.properties
android.useAndroidX=true
android.enableJetifier=true
then adding jetifier will fix it
npm install --save-dev jetifier
npx jetify
npx react-native run-android
that fixed the problem for me.

httpclient conflict with classes now provided by Android

In Android Studio 3.4.1
app/build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
But I get error in this line;
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
error:
httpclient defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. more... (Ctrl+F1)
Check out this changelog for the Android API.
You should replace the Apache HTTP functions by HttpURLConnection or use this snipped in your build.gradle to continue using the now deprecated Apache libraries.
android {
useLibrary 'org.apache.http.legacy'
}

Unable to resolve class org.gradle.util.TestUtil in Gradle

This error means that class TestUtil is not on the classpath and the compiler can not find it. I came across such error hundred times before and there was missing Jar or wrong written class names, but now I just don't know what is wrong.
In my buildSrc dir I have custom Task and I made test for it:
package com.example.core.tasks;
import spock.lang.Specification
import org.gradle.api.Project
import org.gradle.util.TestUtil
public class GetInfoTaskTest extends Specification {
def "check files"(){
given:
def project = TestUtil.createRootProject()
when:
GetInfoTask getInfo = project.tasks.create("getInfo", GetInfoTask)
then:
getInfo instanceof GetInfoTask.class
}
}
In the build script in the buildSrc dir:
dependencies {
compile localGroovy()
testCompile 'org.spockframework:spock-core:0.7-groovy-1.8'
testCompile gradleApi()
}
Error:
GetInfoTaskTest.groovy: 4: unable to resolve class org.gradle.util.TestUtil
# line 3, column 1.
import org.gradle.util.TestUtil
^
I checked that this TestUtil is not internal. I still don't know why gradle can not find it.
TestUtil is an internal class. You can't use it in your own code.