unity iap class not found exception com.unity.purchasing.googleplay.googleplaypurchasing
Hi guys, I was using soomla for iap but i decided to use Unity iap. when i generate a signed apk from android studio, im having AndroidJavaException: java.lang.ClassNotFoundException: com.unity.purchasing.googleplay.GooglePlayPurchasing java.lang.ClassNotFoundException: com.unity.purchasing.googleplay.GooglePlayPurchasing at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:324) at java.lang.Class.forName(Class.java:285) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.a(Unknown Source) at com.unity3d.player.UnityPlayer$b.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.unity.purchasing.googleplay.GooglePlayPurchasing" on path: DexPathList[[zip file "/data/app/com.librasoftworks.graveeGame-2/base.apk"],nativeLibraryDirectories=[/data/app/com.librasoftworks.graveeGame-2/lib/arm, /data/app/com.librasoftworks.graveeGame-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.
im using unity 5.3.4f1 personal, android studio 23(1.7)
anyone can help?
Answer by bazhi · Apr 21, 2016 at 07:50 AM
Unity didn't add some *.aar files to the project. the follow steps are my method to resolve it.
Export Google Android project.
Open Android Studio.
select Import project(Eclipse ADT, Gradle, ect).
select the project you export and open it and clicked Next and Finsh.
Then you can find there is not .aar files in “libs” folder. So you should copy all .aar files to the libs.
Add some code to the build.gradle setting files.
just like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.Gamation.PollQuest"
minSdkVersion 9
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
repositories {
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile files('libs/unity-classes.jar')
compile(name:'common', ext:'aar')
compile(name:'GoogleAIDL', ext:'aar')
compile(name:'GooglePlay', ext:'aar')
}
if you didn't resolve you problem. you can send email to me. my email: bazhicc@163.com
Answer by Enzo1 · Apr 23, 2016 at 04:26 PM
Hi, thanks for your reply. There are several unclear points with your answers:
1 Done
2 Done
3 Done
4 Done
5 You are saying that there are no .aar files in "libs" folder but I have all these .aar files in libs folder
6 I have no build.gradle file as this is not a gradle project.
So the problem persists.
Answer by Tankzo · Nov 23, 2020 at 09:19 PM
This popped up again in Unity IAP 2.2.1
It was fixed by Unity in IAP 2.2.2 today.
Release notes:
Version 2.2.2(current)
Released: Nov 23, 2020
[2.2.2] - 2020-11-20
Fixed
Mac App Store - Support for Apple Silicon, arm64
slice added to binary - GooglePlay - ProductMetadata.localizedPrice no longer floors fractions, e.g. "$19.99" was "$19.00" - GooglePlay - Fix several purchasing-flow issues
OnPurchaseFailed not called after canceled purchase
Exceptions shown in logcat after normal purchase
Purchases of consumables left incomplete, resulting in "product already owned" errors
GooglePlay - Fix initialization when [Android] "Player Settings > Publishing Settings > Minification: Proguard" is enabled. "AndroidJavaException: java.lang.ClassNotFoundException: com.android.billingclient.api.PurchasesUpdatedListener"