ReactVision / viro

ViroReact: The AR and VR library for React Native 📳💙💛🤍💚
MIT License
1.41k stars 164 forks source link

chore: Update android #261

Closed robertjcolley closed 9 months ago

robertjcolley commented 9 months ago

Android build was wildly out of date. This is the culmination of a few days of battling gradle version issues, kotlin version issues, and java version issues. In this commit, viro react compiles with each of the dependencies (renderer, etc.) and creates the bridge properly both in a React Native project and an Expo project.

There's a "hack" in the Expo withViroAndroid.ts file. Expo generates a MainApplication.kt file that doesn't actually add the ViroReact packages to the application.

Todo:

robertjcolley commented 9 months ago

Currently, this branch is crashing for me on the viro-test-bed 3D demo at:

image

Avtrkrb commented 9 months ago

Currently, this branch is crashing for me on the viro-test-bed 3D demo at:

image

@robertjcolley Kotlin plugins need to be v1.8.x or higher v1.6.x is leading to issues. I'm getting similar issues while building my app. Here are the changes I did:

android/build.gradle

dependencies {
        classpath 'com.android.tools.build:gradle:8.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

android/viro_bridge/build.gradle

dependencies {
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.21'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.21"
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.21'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-common:1.8.21'

    implementation 'androidx.appcompat:appcompat:1.0.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.facebook.react:react-native:+'
    implementation project(':arcore_client')
    implementation project(':gvr_common')
    implementation project(':viro_renderer')
    implementation 'com.google.android.exoplayer:exoplayer:2.19.1'
    implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'

    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
    implementation "com.facebook.fresco:fresco:3.1.3"
    implementation "com.facebook.fresco:imagepipeline:3.1.3"
    implementation "com.facebook.fresco:imagepipeline-okhttp3:3.1.3"
    implementation 'com.facebook.fresco:imagepipeline-native:3.1.3'
    implementation 'com.facebook.fresco:memory-type-ashmem:3.1.3'
    implementation "com.facebook.fresco:ui-common:3.1.3"
    implementation "com.facebook.fresco:middleware:3.1.3"
    implementation "com.facebook.fresco:animated-gif:3.1.3"
    implementation 'com.facebook.soloader:nativeloader:0.10.5'
    implementation 'com.facebook.fresco:fbcore:3.1.3'
    implementation 'com.facebook.fresco:drawee:3.1.3'
    implementation 'com.facebook.fresco:memory-type-native:3.1.3'
    implementation 'com.facebook.fresco:memory-type-java:3.1.3'
    implementation 'com.facebook.fresco:nativeimagefilters:3.1.3'
    implementation 'com.facebook.fresco:nativeimagetranscoder:3.1.3'

    implementation fileTree(include: ['*.jar'], dir: 'libs')
}

FYI: I've got these changes in my branch, will open a PR once I'm done testing it out.

Avtrkrb commented 9 months ago

@robertjcolley I've raised a few draft PRs to vircore & viro that should fix a lot of issues for android. It's still WIP though, will tag you once it's ready.

Currently, this branch is crashing for me on the viro-test-bed 3D demo at:

image

My changes should also fix some of these errors.