Skip to content

Unable to open the plugin in Android Studio: gradle fails #28

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

Closed
etiennepinchon opened this issue Dec 25, 2020 · 6 comments
Closed

Unable to open the plugin in Android Studio: gradle fails #28

etiennepinchon opened this issue Dec 25, 2020 · 6 comments

Comments

@etiennepinchon
Copy link

Hey there,

I am trying to open and build the plugin in Android Studio, however I am always getting this error which prevents me from building the project.

A problem occurred configuring project ':app'.
> java.lang.NullPointerException (no error message)

Any idea how to fix it?

@IanPhilips
Copy link
Owner

hm, I haven't seen that before. Did you change anything after cloning the repo?

@IanPhilips
Copy link
Owner

I just pulled from master and built the geckoview plugin project as a library and it worked, so not sure what's wrong with your project.

@bdelo
Copy link

bdelo commented Feb 26, 2021

On windows I was getting a warning along with this of a missing platforms directory in X:/MyUser/AppData/Local/Android/sdk/ndk-bundle. Adding an empty platforms folder to this directory fixed this NullPointerException error for me.

@IanPhilips
Copy link
Owner

Oh that does remind me of some lingering directories in the android studio project that I couldn't seem to delete permanently. I'd suggest @bdelo's answer in just making an emtpy directory with that name in the project root.

@IanPhilips
Copy link
Owner

On windows I was getting a warning along with this of a missing platforms directory in X:/MyUser/AppData/Local/Android/sdk/ndk-bundle. Adding an empty platforms folder to this directory fixed this NullPointerException error for me.

This indeed solved my problem, this time w/ a fresh computer. Insert your user name and run (on mac):
mkdir /Users/{your_user_name}/Library/Android/sdk/ndk-bundle/platforms

@khelkun
Copy link

khelkun commented Jul 31, 2023

To anyone running into the issue reported in the first place, this stackoverflow helped me to figure out the missing configuration.
So "File > Project Structure ... > SDK Location" and choose the default NDK from the dropdown in "AndroidNDK location".

Furthermore to build sucessfuly with the latest Android studio version (2022.3.1), I had to tweak a few things:

  • upgrade gradle into gradle/wrapper/gradle-wrapper.properties:
#Mon Jul 31 17:27:10 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
  • upgrade gradle plugin into build.gradle:
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.2'
  • Enable androidx and jetifier and prevent some kotlin stdlib variant substitution into gradle.properties:
android.enableJetifier=false
android.useAndroidX=true
kotlin.stdlib.jdk.variants.substitution=false
  • Use androidx annotations instead of regular android.support ones, and prevent duplicate classes error about kotlin stdlib app/build.gradle:
dependencies {
    implementation "org.mozilla.geckoview:geckoview${geckoviewChannel}-armeabi-v7a:${geckoviewVersion}"
    implementation project(':classes')
    implementation 'androidx.annotation:annotation:1.6.0'

    constraints {
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
            because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
        }
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
            because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
        }
    }
}
  • Replace imports of annotations in GeckoViewPLugin.java & OVRSurfaceGeckoView.java:
//import android.support.annotation.NonNull;
//import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

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

No branches or pull requests

4 participants