MaxToyberman / react-native-ssl-pinning

React Native ssl pinning and cookies handling based on okhttp3 on (Android). and AFNetworking on (iOS)
MIT License
346 stars 104 forks source link

Fails to build, Android RN 0.59.10 #26

Closed EmperorEarth closed 5 years ago

EmperorEarth commented 5 years ago

Error log

> Task :react-native-ssl-pinning:compileDebugJavaWithJavac FAILED
-path-redacted-\node_modules\react-native-ssl-pinning\android\src\main\java\com\toyberman\RNSslPinningModule.java:25: error: cannot find symbol
import java.util.Base64;
                ^
  symbol:   class Base64
  location: package java.util
-path-redacted-\node_modules\react-native-ssl-pinning\android\src\main\java\com\toyberman\RNSslPinningModule.java:219: error: cannot find symbol
                            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
                                                                           ^
  symbol:   variable O
  location: class VERSION_CODES
-path-redacted-\node_modules\react-native-ssl-pinning\android\src\main\java\com\toyberman\RNSslPinningModule.java:222: error: cannot find symbol
                                base64 = Base64.getEncoder().encodeToString(bytes);
                                         ^
  symbol: variable Base64
Note: -path-redacted-\node_modules\react-native-ssl-pinning\android\src\main\java\com\toyberman\Utils\OkHttpUtils.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-ssl-pinning: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 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s
77 actionable tasks: 69 executed, 8 up-to-date
error 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
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

my android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.0")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        jcenter()
        maven { url "https://jitpack.io" }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}
$ java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

$ javac -version
javac 1.8.0_221

$ ./gradlew -v

------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_221 (Oracle Corporation 25.221-b11)
OS:           Windows 7 6.1 amd64
EmperorEarth commented 5 years ago

PR #27

EmperorEarth commented 5 years ago

If you don't want to bump the compileSdkVersion and buildToolsVersion to 26.x, you can import android.util.Base64; instead of import java.util.Base64; on Line 25 and use 26 instead of Build.VERSION_CODES.O on Line 219. There's probably more changes you'd have to make--I didn't chase down that rabbit hole--but I don't see any reason why it needs to require 26.x+

MaxToyberman commented 5 years ago

@EmperorEarth version 1.3.5 was released. please check it