不能 运行 我的项目在 android 工作室在我的 MacBook 与 M1 Pro 芯片

Can't run my project in android studio in my MacBook with M1 Pro chip

我无法在配备 M1 Pro 芯片的 MacBook Pro 上 运行 我的 Android Studio 项目,但它可以在 Windows 和 MacBook Pro 上 运行英特尔芯片。

这是我的错误:

    > Task :app:compileDebugJavaWithJavac FAILED
    Execution failed for task ':app:compileDebugJavaWithJavac'.
    > java.lang.ExceptionInInitializerError
    
    * 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.

Here is stacktrace result:

        
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '/Users/User/Downloads/FindMeHomeApp-master 2/app/build.gradle'
    
    * What went wrong:
    Could not compile build file '/Users/User/Downloads/FindMeHomeApp-master 2/app/build.gradle'.
    > startup failed:
      General error during conversion: Unsupported class file major version 61
      
      java.lang.IllegalArgumentException: Unsupported class file major version 61
      

  at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:189)
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:170)
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:156)
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:277)

这里有很多行开始于 :

在 org.codehaus。

或 在 groovy.lang.

或 在 org.gradle.


 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.base/java.lang.Thread.run(Thread.java:833)
  
      1 error
    
    
    * 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 8.0.
    Use '--warning-mode all' to show the individual deprecation warnings.
    See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
    
    BUILD FAILED in 1s

回答我的问题

使用M1/M1 Pro芯片的朋友请使用Room 2.4.0-alpha03

def room_version = "2.4.0-alpha03"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"