forcedotcom / SalesforceMobileSDK-Android

Android SDK for Salesforce
Other
341 stars 388 forks source link

getBuildConfigValue failed #2606

Open johnjeremih opened 2 months ago

johnjeremih commented 2 months ago

Please fill out the following details:

  1. Version of Mobile SDK Used: 12.0.0
  2. Issue found in Native App or Hybrid App: Native
  3. OS Version: 34
  4. Device: Pixel 6a
  5. Steps to reproduce: I have target sdk 34 and gradle version 8.3.0
  6. Actual behavior:
  7. Expected Behavior:
  8. Error Log: getBuildConfigValue failed (Ask Gemini) java.lang.ClassNotFoundException: com.myapp.nativeandroid.dev.BuildConfig at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:536) at java.lang.Class.forName(Class.java:467) at com.salesforce.androidsdk.app.SalesforceSDKManager.getBuildConfigValue(SalesforceSDKManager.kt:1356) at com.salesforce.androidsdk.app.SalesforceSDKManager.isDebugBuild(SalesforceSDKManager.kt:1338) at com.salesforce.androidsdk.app.SalesforceSDKManager.isDevSupportEnabled(SalesforceSDKManager.kt:440) at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.setupDeveloperSupport(SalesforceSDKManager.kt:1635) at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.initInternal(SalesforceSDKManager.kt:1556) at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.init(SalesforceSDKManager.kt:1525) at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.init$default(SalesforceSDKManager.kt:1511) at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.initNative(SalesforceSDKManager.kt:1589) at com.myapp.nativeandroid.MyAppApplication.onCreate(MyAppApplication.kt:25) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6998) at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myapp.nativeandroid.dev.BuildConfig" on path: DexPathList[[dex file "/data/data/com.myapp.nativeandroid.dev/code_cache/.overlay/base.apk/classes17.dex", dex file "/data/data/com.myapp.nativeandroid.dev/code_cache/.overlay/base.apk/classes30.dex", dex file "/data/data/com.myapp.nativeandroid.dev/code_cache/.overlay/base.apk/classes14.dex", dex file "/data/data/com.myapp.nativeandroid.dev/code_cache/.overlay/base.apk/classes10.dex", dex file "/data/data/com.myapp.nativeandroid.dev/code_cache/.overlay/base.apk/classes15.dex", dex file "/data/data/com.myapp.nativeandroid.dev/code_cache/.overlay/base.apk/classes4.dex", dex file "/data/data/com.myapp.nativeandroid.dev/code_cache/.overlay/base.apk/classes19.dex", zip file "/data/app/~~mZPx7yWkw657t5cBQ0QqaQ==/com.myapp.nativeandroid.dev-EdJYVKDpJc1cJgGSuedhqg==/base.apk"],nativeLibraryDirectories=[/data/app/~~mZPx7yWkw657t5cBQ0QqaQ==/com.myapp.nativeandroid.dev-EdJYVKDpJc1cJgGSuedhqg==/lib/arm64, /system/lib64, /system_ext/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at java.lang.Class.classForName(Native Method)  at java.lang.Class.forName(Class.java:536)  at java.lang.Class.forName(Class.java:467)  at com.salesforce.androidsdk.app.SalesforceSDKManager.getBuildConfigValue(SalesforceSDKManager.kt:1356)  at com.salesforce.androidsdk.app.SalesforceSDKManager.isDebugBuild(SalesforceSDKManager.kt:1338)  at com.salesforce.androidsdk.app.SalesforceSDKManager.isDevSupportEnabled(SalesforceSDKManager.kt:440)  at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.setupDeveloperSupport(SalesforceSDKManager.kt:1635)  at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.initInternal(SalesforceSDKManager.kt:1556)  at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.init(SalesforceSDKManager.kt:1525)  at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.init$default(SalesforceSDKManager.kt:1511)  at com.salesforce.androidsdk.app.SalesforceSDKManager$Companion.initNative(SalesforceSDKManager.kt:1589)  at com.myapp.nativeandroid.MyAppApplication.onCreate(MyAppApplication.kt:25)  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6998)  at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loopOnce(Looper.java:205)  at android.os.Looper.loop(Looper.java:294)  at android.app.ActivityThread.main(ActivityThread.java:8177)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 
Techfhil commented 1 month ago

To resolve the getBuildConfigValue failed issue, I recommend the following steps:

Verify Build Configuration: Ensure your build.gradle file contains the correct application ID and that there are no misconfigurations. Double-check that the applicationId matches the package name where the BuildConfig class is expected.

Clean and Rebuild: Execute a clean build of your project to regenerate the necessary files. You can do this by running:

./gradlew clean assembleDebug This will help ensure that the BuildConfig class is properly generated.

Check Package Structure: Confirm that the BuildConfig class is being generated in the correct package. You can do this by inspecting the APK or build output directory to ensure it exists at com.myapp.nativeandroid.dev.BuildConfig.

Gradle Sync Issues: Sometimes, Gradle sync problems can lead to missing classes. Make sure that all dependencies are correctly included and that there are no conflicts. Try invalidating caches in Android Studio (File -> Invalidate Caches / Restart).

Use Debug Variants: If you're working with product flavors or build variants, ensure you're accessing the correct variant of the BuildConfig class. If using different variants for debug and release builds, check if the issue arises only in a specific variant.

Consult Documentation: If the issue persists, refer to the Salesforce SDK documentation for any specific requirements related to BuildConfig and ensure that your implementation aligns with their guidelines.

Implementing these steps should help resolve the ClassNotFoundException for BuildConfig and restore expected functionality. If the problem continues, sharing additional context about recent changes made in the project may help diagnose the issue further