Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in thread "main" java.lang.IllegalArgumentException #830

Closed
sethjdev opened this issue Aug 14, 2018 · 7 comments
Closed

Exception in thread "main" java.lang.IllegalArgumentException #830

sethjdev opened this issue Aug 14, 2018 · 7 comments
Labels

Comments

@sethjdev
Copy link

sethjdev commented Aug 14, 2018

Trying to compile my Android app with this package. Will not build. I have followed the Android installation guidelines to a T. Error only occurs when the changes from the Android installation guide are made, when I comment out those changes, the app builds fine, so the problem ONLY occurs when attempting to build the project with this package.

My app:
react-native: 0.55.4
react-native-push-notification 3.1.1
compileSdkVersion 27
buildToolsVersion '27.0.3'

Error from console (after running react-native run-android)

Exception in thread "main" java.lang.IllegalArgumentException
       at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
       at com.google.devtools.build.android.desugar.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:483)
       at org.objectweb.asm.ClassReader.accept(ClassReader.java:621)
       at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
       at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.defaultMethodsDefined(DefaultMethodClassFixer.java:331)
       at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.visitEnd(DefaultMethodClassFixer.java:91)
       at org.objectweb.asm.ClassVisitor.visitEnd(ClassVisitor.java:339)
       at com.google.devtools.build.android.desugar.InterfaceDesugaring.visitEnd(InterfaceDesugaring.java:112)
       at org.objectweb.asm.ClassReader.accept(ClassReader.java:702)
       at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
       at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:477)
       at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:361)
       at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:314)
       at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:711)

android/settings.gradle

rootProject.name = '******'
...
include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = file('../node_modules/react-native-push-notification/android')
include ':app'

android/app/build.gradle

...
apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.android.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "*******"
        minSdkVersion 16
        targetSdkVersion 27
        vectorDrawables.useSupportLibrary = true
        versionCode 1
        versionName "1.0"
        // Enabling multidex support.
        multiDexEnabled true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile project(':react-native-push-notification')
    ...
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:27.1.0'
    compile 'com.facebook.react:react-native:+'
    // From node_modules
    compile 'com.android.support:design:27.1.0'
}
...

android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.******app">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <permission
        android:name="${applicationId}.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:theme="@style/AppTheme"
        tools:replace="android:allowBackup">
        <activity
            android:name=".SplashActivity"
            android:theme="@style/SplashTheme"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustPan"
          android:exported="true">
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
         <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>
        
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
        <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>
    </application>

</manifest>

android/app/src/main/java/com/{APP_NAME}/MainApplication.java

package com.*****app;

import android.app.Application;
...
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

        @Override
        protected String getJSBundleFile() {
        return CodePush.getJSBundleFile();
        }
    
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
           ...
            new ReactNativePushNotificationPackage()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index.android";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    ...
  }
}

@sethjdev
Copy link
Author

I have resolved this issue by changing my SDK version from 27 to 26. And my Java version from 1.8 to 1.7.

@felansu
Copy link

felansu commented Sep 20, 2018

+1 here, same problem

@ammichael
Copy link

ammichael commented Sep 21, 2018

I too have this problem, and unfortunately I can't downgrade my Java to 1.7. Any ideas?
@zo0r, I think with RN 0.57 this problem will start to happen ofter

@danibonilha
Copy link
Contributor

As specified in this link:
https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html

Prior to version 15 firebase and google-play-services, should have the same version, in our project we specified googlePlayServicesVersion to 11, but not firebaseVersion. Specifying the same version for both in android/build.gradle worked like a charm!

@addMind-me
Copy link

Same issue. I'm using the v2 of react-native-navigation and I need to use java 1.8 and min sdk 19. Any ideas how solve this issue? I'm in a hurry to solve this. =[

@danibonilha
Copy link
Contributor

@addMind-me which version of googlePlayservices and firebase are you using in your project ? If any of these versions are prior to 15 they need to be the same, as described here, if it's 11.2.0 for example, you need do this:

googlePlayServicesVersion = "11.2.0"
firebaseVersion = "11.2.0"

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants