[SOLVED] SDKBox review plugin not working in android

Can I take a look at your project.properties file?

Sure.

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-20

android.library.reference.1=..\\cocos2d\\cocos\\platform\\android\\java
android.library.reference.2=../cocos2d/cocos/platform/android/java/libs/facebook_lib
android.library.reference.3=../cocos2d/cocos/platform/android/java/libs/facebook_lib/libs/gps/

I could install review plugin changing android.library.reference but both my google analytics & review plugins not working. Logcat logs that google analytics starting but it’s not logged in analytics dashboard. I created tracker 3 days ago. Using samples of review does not work for me.
By the way, i think this is strange. Here is my C:\CocosProjects\Kelimece\cocos2d\cocos\platform\android\java\libs structure:

android-support-v4.jar
PluginFacebook.jar
PluginReview.jar
sdkbox.jar
/facebook_lib ->
                     /libs ->
                              /facebook_lib
                              /gps
                              android-support-v4.jar
                              PluginGoogleAnalytics.jar
                              PluginGooglePlay.jar
                              PluginIAP.jar
                              bolts-android-1.1.2.jar
                              PluginReview.jar

Am i wrong?

@hgokturk

in project.properties file
android.library.reference.1=..\\cocos2d\\cocos\\platform\\android\\java
should be
android.library.reference.1=../cocos2d/cocos/platform/android/java,

and, we will fix this, in next version

Yes, exactly that change solves the issue.

Hi,
I try to use plugin review, but I am getting :frowning: :
What could be issue, please?

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sdkbox/plugin/review/R$string;
                                                       at org.codechimp.apprater.AppRater.getPromptTitle(AppRater.java:427)
                                                       at org.codechimp.apprater.AppRater.showRateAlertDialog(AppRater.java:298)
                                                       at org.codechimp.apprater.AppRater.tryShowDialog(AppRater.java:223)
                                                       at com.sdkbox.plugin.PluginReview$1.run(PluginReview.java:55)
                                                       at android.os.Handler.handleCallback(Handler.java:739)
                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                       at android.os.Looper.loop(Looper.java:135)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5297)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
                                                    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sdkbox.plugin.review.R$string" on path: DexPathList[[zip file "/data/app/com.tuneinstrument.violintunersimple-2/base.apk"],nativeLibraryDirectories=[/data/app/com.tuneinstrument.violintunersimple-2/lib/arm, /vendor/lib, /system/lib]]
                                                       at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                       at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                       at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                       at org.codechimp.apprater.AppRater.getPromptTitle(AppRater.java:427) 
                                                       at org.codechimp.apprater.AppRater.showRateAlertDialog(AppRater.java:298) 
                                                       at org.codechimp.apprater.AppRater.tryShowDialog(AppRater.java:223) 
                                                       at com.sdkbox.plugin.PluginReview$1.run(PluginReview.java:55) 
                                                       at android.os.Handler.handleCallback(Handler.java:739) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                       at android.os.Looper.loop(Looper.java:135) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5297) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at java.lang.reflect.Method.invoke(Method.java:372) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703) 
                                                   	Suppressed: java.lang.ClassNotFoundException: com.sdkbox.plugin.review.R$string
                                                       at java.lang.Class.classForName(Native Method)
                                                       at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                       at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                       at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                       		... 13 more
                                                    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

can you double check if your project is missing sdkbox_config.json?

sdkbox_config.json is in proj.android-studio/app/assets folder and also in Resources folder. What could be issue, please?

It looks like it is crashing with the above exception log in the case I remove strange text from sdkbox_config.json.

Why the hell is there “custome tile” and other nonsence? What I should put there instead?

Why there are proper and correct language files with proper text in multiple languages? Why the text is not displayed from there instead?

{
    "android": {
        "Review": {
            "LaunchLimit": 3, 
            "promptTitle": "cutome tile", 
            "promptRate": "rate\u6253\u5206", 
            "DayForReminding": 1, 
            "promptRateLater": "\u7a0d\u540elater", 
            "tryPromptWhenInit": true, 
            "promptCancel": "\u53d6\u6d88", 
            "promptMessage": "this is custome message", 
            "DayLimit": 0, 
            "LaunchForReminding": 2, 
            "UserEventLimit": 0
        }
    }, 
    "ios": {
        "Review": {
            "LaunchLimit": 3, 
            "promptTitle": "cutome tile", 
            "promptRate": "rate\u6253\u5206", 
            "DayForReminding": 1, 
            "promptRateLater": "\u7a0d\u540elater", 
            "tryPromptWhenInit": true, 
            "AppID": "1234567890", 
            "promptCancel": "\u53d6\u6d88", 
            "promptMessage": "this is custome message", 
            "DayLimit": 0, 
            "LaunchForReminding": 2, 
            "UserEventLimit": 0
        }
    }
}

If I do this to sdkbox_config.json, it crashes on Android:
(on iOS, it displays correctly text from language files)

{
    "android": {
        "Review": {
            "LaunchLimit": 3, 
            "DayForReminding": 1, 
            "tryPromptWhenInit": true,
            "DayLimit": 0, 
            "LaunchForReminding": 2, 
            "UserEventLimit": 0
        }
    }, 
    "ios": {
        "Review": {
            "LaunchLimit": 3,
            "DayForReminding": 1,
            "tryPromptWhenInit": true,
            "AppID": "1234567890", 
            "DayLimit": 0, 
            "LaunchForReminding": 2, 
            "UserEventLimit": 0
        }
    }
}

If I do it this way, the language text is not still displayed correctly:
(there are displayed @string/dialog_title, @string/rate, @string/later, @string/no_thanks, etc…)

    {
    "android": {
        "Review": {
            "LaunchLimit": 3,
            "promptTitle": "@string/dialog_title",
            "promptRate": "@string/rate",
            "DayForReminding": 1,
            "promptRateLater": "@string/later",
            "tryPromptWhenInit": true,
            "promptCancel": "@string/no_thanks",
            "promptMessage": "@string/rate_message",
            "DayLimit": 0, 
            "LaunchForReminding": 2, 
            "UserEventLimit": 0
        }
    }, 
    "ios": {
        "Review": {
            "LaunchLimit": 3,
            "DayForReminding": 1,
            "tryPromptWhenInit": true, 
            "AppID": "1234567890",
            "DayLimit": 0, 
            "LaunchForReminding": 2, 
            "UserEventLimit": 0
        }
    }
}

In the sdkbox review plugin documentation, there is written:

Note: if you set tryPromptWhenInit to true which is in sdkbox.config, you must call the following functions before init():

sdkbox::PluginReview::setTitle(“custom title”);
sdkbox::PluginReview::setMessage(“custom message”);
sdkbox::PluginReview::setCancelButtonTitle(“custom cancel”);
sdkbox::PluginReview::setRateButtonTitle(“custom rate”);
sdkbox::PluginReview::setRateLaterButtonTitle(“custom rate later”);

Yes, I have tryPromptWhenInit set to true.
But what to use in this functions to display content of language files?

You can’t specify language string in the config file, since they’re not part of the compile pipeline of android, if you want to customize the localization of texts, I suggest to change the review lib project

You can take a look our sample file.

seem like can’t find resource R, the R should be in lib project plugin_review_res_project, can you find it in proj.andorid folder.

The issue is that if promptTitle, promptRate, promptRateLater, promptCancel, promptMessage is not specified in review configuration file sdkbox_config.json and if tryPromptWhenInit is true, then it crashes on start of the app on Android.

But it works perfectly on iOS.

I wish if it would work also on Android the same way. But how to achieve that?

PS: I do not wish to customize review plugin texts at all. I just wish that it would work with default text from language files. plugin_review_res_project content is already included in the res folder of proj.android-studio/app/res folder.

But on Android it rather crashes if tryPromptWhenInit is true and if promptTitle, promptRate, promptRateLater, promptCancel, promptMessage is not specified in review configuration file. Based on documentation I should specify

sdkbox::PluginReview::setTitle(“custom title”);
sdkbox::PluginReview::setMessage(“custom message”);
sdkbox::PluginReview::setCancelButtonTitle(“custom cancel”);
sdkbox::PluginReview::setRateButtonTitle(“custom rate”);
sdkbox::PluginReview::setRateLaterButtonTitle(“custom rate later”);

before call init(), in the case tryPromptWhenInit is set to true.

But how to set them, if you wish just to use text from language files (on Android)?
(on iOS, no issue at all)

@nov did you compile with android studio

Yes. With cocos compile -p android --android-studio

i reproduce the issue when compile with android studio ( cocos run -p android --android-studio)
compile with eclipse is ok( cocos run -p android )

reason of this issue is plugin_review_res_project was not include by android-studio project.

  • you can wait our new version of review. (just one or two days)

  • or, you can fix by your self.

here is fix steps:

  1. add a new file $PROJ_ROOT/proj.android/plugin_review_res_project/build.gradle
  2. modify file $PROJ_ROOT/proj.android-studio/settings.gradle
  3. modify file $PROJ_ROOT/proj.android/plugin_review_res_project/AndroidManifest.xml
  4. modify file $PROJ_ROOT/cocos2d/cocos/platform/android/libcocos2dx/build.gradle

Content of file $PROJ_ROOT/proj.android/plugin_review_res_project/build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }

    sourceSets.main {
        res.srcDir "res"
        manifest.srcFile "AndroidManifest.xml"
    }
}

Content of file $PROJ_ROOT/proj.android-studio/settings.gradle:

...

//include review plugin resource project
include ':libPluginReviewResource'
project(':libPluginReviewResource').projectDir = new File(settingsDir, '../proj.android/plugin_review_res_project')

Content of file $PROJ_ROOT/proj.android/plugin_review_res_project/AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.sdkbox.plugin.review">
</manifest>

Content of file $PROJ_ROOT/cocos2d/cocos/platform/android/libcocos2dx/build.gradle:

....
dependencies {
    ...
    compile project(':libPluginReviewResource')
}
...

Thank you for providing details and solution.

What I currently have is that all the values, values-x… folders (with strings.xml file in each of them) are copied in proj.android-studio/app/res folder already.

Should not such solution work already, please?

PS: I have there other values in res folder values subfolder already which are used eg. colors.xml, styles.xml and strings.xml. Also other folders for images and icon mipmap and drawable. Which are found by the App without any issue.


Review find resource by com.sdkbox.review.R, you copy value to app,the resource R is under you.package.name.R, review can not know your package name, so should not copy to app folder

The solution above helped to solve the observed issue. Thanks!

I HAVE SIMILAR ISSUE,

03-14 10:50:31.689: E/AndroidRuntime(19352): FATAL EXCEPTION: main
03-14 10:50:31.689: E/AndroidRuntime(19352): Process: com.ort.arproj, PID: 19352
03-14 10:50:31.689: E/AndroidRuntime(19352): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sdkbox/plugin/review/R$string;
03-14 10:50:31.689: E/AndroidRuntime(19352): at org.codechimp.apprater.AppRater.getPromptTitle(AppRater.java:466)
03-14 10:50:31.689: E/AndroidRuntime(19352): at org.codechimp.apprater.AppRater.showRateAlertDialog(AppRater.java:304)
03-14 10:50:31.689: E/AndroidRuntime(19352): at org.codechimp.apprater.AppRater.showRateDialog(AppRater.java:236)
03-14 10:50:31.689: E/AndroidRuntime(19352): at com.sdkbox.plugin.PluginReview$2.run(PluginReview.java:69)
03-14 10:50:31.689: E/AndroidRuntime(19352): at android.os.Handler.handleCallback(Handler.java:742)
03-14 10:50:31.689: E/AndroidRuntime(19352): at android.os.Handler.dispatchMessage(Handler.java:95)
03-14 10:50:31.689: E/AndroidRuntime(19352): at android.os.Looper.loop(Looper.java:157)
03-14 10:50:31.689: E/AndroidRuntime(19352): at android.app.ActivityThread.main(ActivityThread.java:5571)
03-14 10:50:31.689: E/AndroidRuntime(19352): at java.lang.reflect.Method.invoke(Native Method)
03-14 10:50:31.689: E/AndroidRuntime(19352): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
03-14 10:50:31.689: E/AndroidRuntime(19352): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
03-14 10:50:31.689: E/AndroidRuntime(19352): Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.sdkbox.plugin.review.R$string” on path: DexPathList[[zip file “/data/app/com.ort.arproj-1/base.apk”],nativeLibraryDirectories=[/data/app/com.ort.arproj-1/lib/arm, /data/app/com.ort.arproj-1/base.apk!/lib/armeabi, /vendor/lib, /system/lib]]
03-14 10:50:31.689: E/AndroidRuntime(19352): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-14 10:50:31.689: E/AndroidRuntime(19352): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-14 10:50:31.689: E/AndroidRuntime(19352): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
03-14 10:50:31.689: E/AndroidRuntime(19352): … 11 more
03-14 10:50:31.689: E/AndroidRuntime(19352): Suppressed: java.lang.ClassNotFoundException: com.sdkbox.plugin.review.R$string
03-14 10:50:31.689: E/AndroidRuntime(19352): at java.lang.Class.classForName(Native Method)
03-14 10:50:31.689: E/AndroidRuntime(19352): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
03-14 10:50:31.689: E/AndroidRuntime(19352): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
03-14 10:50:31.689: E/AndroidRuntime(19352): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
03-14 10:50:31.689: E/AndroidRuntime(19352): … 12 more
03-14 10:50:31.689: E/AndroidRuntime(19352): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

I follow the above instructions but any working for me. My project is an a cocos c++ over eclipse enviroment. when you execute the comand sdkbox import review for example, if you go to root of your project you can se a new folder called plugin_review_res_project, to solve this type of issue, you must go to properties of you project an verify in the Android section if the library is added to your porject
i you see some like the picture.

If you see a red cross in the second library, yo need import the project to resolve issue.
Rebuild all, a clean your projects.