google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 604 forks source link

app is crashing #248

Closed basitsaleemmb closed 6 years ago

basitsaleemmb commented 6 years ago

@malik-at-work @inio @gstanlo this is the crash i'm getting, I have initialized ArFragment in my onCreate. In my gradle file i have multiDexEnable = true. Looking for help!
When i am using ARScene project independently it works fine, but when i use it in my peoject as module i got the error given below.

java.lang.NoSuchMethodError: No virtual method requireActivity()Landroid/support/v4/app/FragmentActivity; in class Lcom/google/ar/sceneform/ux/BaseArFragment; or its super classes (declaration of 'com.google.ar.sceneform.ux.BaseArFragment' appears in /data/app/com.tipestrygo.lenovo.tipestry-1/base.apk:classes7.dex) at com.google.ar.sceneform.ux.BaseArFragment.requestDangerousPermissions(BaseArFragment.java:264) at com.google.ar.sceneform.ux.BaseArFragment.onCreateView(BaseArFragment.java:213) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2261) at android.support.v4.app.FragmentManagerImpl.ensureInflatedFragmentView(FragmentManager.java:1655) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1390) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1650) at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1906) at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3698) at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111) at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:350) at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39) at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:784) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734) at android.view.LayoutInflater.rInflate(LayoutInflater.java:865) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828) at android.view.LayoutInflater.inflate(LayoutInflater.java:525) at android.view.LayoutInflater.inflate(LayoutInflater.java:427) at android.view.LayoutInflater.inflate(LayoutInflater.java:378) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.tipestrygo.lenovo.tipestry.Activities.CoreArActivities.LocationActivity.onCreate(LocationActivity.java:84) at android.app.Activity.performCreate(Activity.java:6912) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3001) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1643) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6642) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

basitsaleemmb commented 6 years ago

is anybody open for help!

malik-at-work commented 6 years ago

I would double check the multidex config in your build.gradle file. what is your minSdkVersion set to? Also check what dependencies you have setup. requireActivity was added to android support library in version 27.1

basitsaleemmb commented 6 years ago

@malik-at-work minSdk version is set to 17 Support library is 26.1.0

here you go my build.gradle buildscript { repositories { maven { url 'https://maven.fabric.io/public' } }

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}

} apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'io.fabric'

repositories { maven { url 'https://maven.fabric.io/public' } mavenCentral() }

android { lintOptions { checkReleaseBuilds false // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError false } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } compileSdkVersion 26 defaultConfig { applicationId "com.tipestrygo.lenovo.tipestry" minSdkVersion 17 targetSdkVersion 26 versionCode 5 versionName "2.1.3" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true } buildTypes { release { shrinkResources false minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } aaptOptions { cruncherEnabled false }

compileOptions {
    targetCompatibility 1.8
    sourceCompatibility 1.8
}

}

dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.facebook.android:facebook-android-sdk:[4,5)' implementation 'com.android.support:design:26.1.0' implementation 'com.android.support:support-v4:26.1.0' // implementation 'com.google.android.gms:play-services-maps:11.8.0' // implementation 'com.google.firebase:firebase-auth:11.8.0' // implementation 'com.google.android.gms:play-services-auth:11.8.0' // testImplementation 'junit:junit:4.12' // androidTestImplementation 'com.android.support.test:runner:1.0.1' // androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' implementation 'de.hdodenhof:circleimageview:2.1.0' implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.google.code.gson:gson:2.8.2' implementation 'android.arch.lifecycle:extensions:1.1.0' implementation 'com.android.support:recyclerview-v7:26.1.0' implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.github.bumptech.glide:glide:3.8.0' implementation 'com.android.support:cardview-v7:26.1.0' implementation 'com.github.ceryle:SegmentedButton:v2.0.2' implementation 'me.biubiubiu.justifytext:library:1.1' implementation 'com.squareup.retrofit2:retrofit:2.3.0' implementation 'com.squareup.retrofit2:converter-gson:2.2.0' implementation 'de.hdodenhof:circleimageview:2.2.0' implementation 'com.google.android.exoplayer:exoplayer:2.6.1' implementation 'it.sephiroth.android.library.imagezoom:imagezoom:2.3.0' implementation 'com.afollestad:easyvideoplayer:0.3.0' implementation 'info.hoang8f:android-segmented:1.0.6' implementation 'com.wang.avi:library:2.1.3' implementation 'com.google.android.gms:play-services:11.8.0' implementation 'com.amazonaws:aws-android-sdk-core:2.6.+' implementation 'com.amazonaws:aws-android-sdk-s3:2.6.+' implementation 'com.amazonaws:aws-android-sdk-ddb:2.6.+' implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') { transitive = true } implementation 'com.makeramen:roundedimageview:2.3.0' implementation 'com.roughike:bottom-bar:2.0.2' implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0' implementation 'com.daimajia.swipelayout:library:1.2.0@aar' // implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'org.greenrobot:eventbus:3.1.1' implementation 'net.sharewire:google-maps-clustering:0.1.3' implementation 'q.rorbin:badgeview:1.1.3' implementation 'com.google.firebase:firebase-messaging:11.8.0' implementation project(':arcore-location')

implementation 'com.android.support:multidex:1.0.2'
implementation "com.google.ar.sceneform:core:1.3.0"
implementation "com.google.ar.sceneform.ux:sceneform-ux:1.3.0"
implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:6.0.2@aar') {
    transitive = true
}
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.5.3'

// implementation('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0@aar') { // transitive = true // } compile('com.crashlytics.sdk.android:crashlytics-ndk:2.0.4@aar') { transitive = true } compile 'org.sufficientlysecure:html-textview:3.5' compile 'com.miguelcatalan:materialsearchview:1.4.0'

}

apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android-extensions'

crashlytics { enableNdk true androidNdkOut 'src/main/obj' androidNdkLibsOut 'src/main/libs' }

apply plugin: 'com.google.ar.sceneform.plugin'

sceneform.asset('sampledata/models/w.obj', 'default', 'sampledata/models/w.sfa', 'src/main/res/raw/w')

basitsaleemmb commented 6 years ago

@malik-at-work @inio @gstanlo fixed when i have updated my support library to 27.1.1. But getting another one now

got this issue in sceneform 1.4.0 minSdK = 17 supportLibrary = 27.1.1 phone samsung s7 galaxy OS = 8.0.0

Fatal Exception: java.lang.IllegalStateException: Texture must use ARGB8 format. at com.google.ar.sceneform.rendering.Texture$LoadTextureTask.loadData(Texture.java:299) at com.google.ar.sceneform.rendering.AssetLoader.lambda$runLoadTask$0$AssetLoader(AssetLoader.java:81) at com.google.ar.sceneform.rendering.AssetLoader$$Lambda$0.run(Unknown Source:8) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

malik-at-work commented 6 years ago

@basitsaleemmb I've opened a new issue to discuss the new issue, check out #254

Closing this issue, so that threads are kept to one topic.

nbazos commented 6 years ago

@malik-at-work I am experiencing the same exact issue as @basitsaleemmb, however, updating the support library to 27.1.1 did not fix the issue for me.

I used this statement in my app's build.gradle dependencies section: implementation "com.android.support:support-core-utils:27.1.1" Is this correct?

Thank you in advance for your help.

minSdK = 24 supportLibrary = 27.1.1 phone = Samsung S8 Galaxy Plus OS = 8.0.0

app build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.rrh.wayfinder"
        minSdkVersion 24 // >= 24 for AR Required Apps...>=14 for AR Optional Apps
        targetSdkVersion 27
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation "com.indooratlas.android:indooratlas-android-sdk:2.7.0@aar"
    implementation 'com.indooratlas.android:indooratlas-android-wayfinding:2.7.1'

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.google.android.gms:play-services-maps:8.1.0'
    implementation 'com.google.maps.android:android-maps-utils:0.3.+'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.2.0'
    // implementation 'com.pubnub:pubnub-android:3.7.5'
    implementation 'com.android.support:design:27.0.2'

    // for Open Street Map support
    implementation 'org.osmdroid:osmdroid-android:5.6.4'
    // implementation 'com.github.MKergall:osmbonuspack:6.2'

    // AR
    implementation 'com.google.ar.sceneform:core:1.4.0'
    implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.4.0'
    implementation "com.android.support:support-core-utils:27.1.1"

    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'
}

repositories {
    maven {
        url "http://indooratlas-ltd.bintray.com/mvn-public"
        google()
    }
}

apply plugin: 'com.google.ar.sceneform.plugin'

sceneform.asset('sampledata/Arrow.fbx',
        'default',
        'sampledata/Arrow.sfa',
        'src/main/assets/Arrow')

project build.gradle:

// 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.1.3'
        classpath 'com.google.ar.sceneform:plugin:1.4.0'

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

onCreate:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        // AR
        fragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.ux_fragment);

        // dropdown destinations
        Spinner spinner = (Spinner) findViewById(R.id.destination_list);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.destinations_array, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
        spinner.setAdapter(adapter);

        spinner.setOnItemSelectedListener(this);

        // prevent the screen going to sleep while app is on foreground
        findViewById(android.R.id.content).setKeepScreenOn(true);

        // instantiate IALocationManager and IAResourceManager
        mIALocationManager = IALocationManager.create(this);
        mIAResourceManager = IAResourceManager.create(this);

        // Request GPS locations
        if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{ACCESS_FINE_LOCATION}, MY_PERMISSION_ACCESS_FINE_LOCATION);
            return;
        }

        startListeningPlatformLocations();

        String graphJSON = loadGraphJSON();
        if (graphJSON == null) {
            Toast.makeText(this, "Could not find wayfinding_graph.json from raw " +
                    "resources folder. Cannot do wayfinding.", Toast.LENGTH_LONG).show();
        } else {
            mWayfinder = IAWayfinder.create(this, graphJSON);
        }
    }

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/PLAY_PARENT"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    tools:layout_editor_absoluteY="81dp">

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/map"
        tools:context=".MapsActivity"
        android:name="com.google.android.gms.maps.SupportMapFragment"/>

    <fragment android:name="com.google.ar.sceneform.ux.ArFragment"
        android:id="@+id/ux_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <Spinner
        android:id="@+id/destination_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:drawable/btn_dropdown"
        android:spinnerMode="dropdown"/>
</android.support.constraint.ConstraintLayout>
malik-at-work commented 6 years ago

My guess based on the files posted would be to check the dependencies. I notice: implementation 'com.android.support:design:27.0.2' implementation 'com.android.support:appcompat-v7:27.0.2'

nbazos commented 6 years ago

@malik-at-work Thank you for pointing those out, I had to change them to 27.1.1 and now it works. Cheers!

ChanduMnS commented 4 years ago

Hi @nbazos , @malik-at-work , my app is still crashing with the out of memory exception. It's happening very frequently. Like every time I open the app. I'm using a SFB file to render the model. I'm using 27.1.0. Kindly help me out. For more log details please refer : #1034 https://github.com/google-ar/sceneform-android-sdk/issues/1034#issue-590223837