Shin-NiL / Godot-Android-Admob-Plugin

Android AdMob plugin for Godot Game Engine 3.2 or higher
MIT License
549 stars 67 forks source link

[Android] Game does not open #94

Closed Biri0 closed 4 years ago

Biri0 commented 4 years ago

Godot version: 3.2.2

AdMob Plugin version: 4.1.1

Issue description: When I export the game to android the game quits and I get this error. Can someone help me?

java.lang.ClassNotFoundException: Didn't find class "org/ godotengine/godot/GodotAdMob" on path: DexPathList[[zip file
"/data/app/org.godotengine.test-hc84H_rdVM7NUrIK_nJAnw==/ base.apk"],nativeLibraryDirectories=[/data/app/
org.godotengine.test-hc84H_rdVM7NUrIK_nJAnw=/lib/arm64, / data/app/org.godotengine.test-hc84H_rdVM7NUrIK_nJAnw==/
base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoa
der.java:171) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at
org.godotengine.godot.GodotLib.setup(Native Method) 
at org.godotengine.godot.Godot$2.run(Godot.java:347) at 
android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1500) at
android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.ja va:1270)
kamyabnazari commented 4 years ago

Hi @BirioGames , from reading the Exception message it seams like the AdMob plugin class is not being added into you final Apk after you export it. Are you including the plugin in your final export?

I would suggest as @Shin-NiL has stated on the readme, that you should first export the project without the plugin first and then test it with.

this plugin is Android only, so the AdMob Java singleton will only exists on the Android platform. In other words, you will be able to run it on an Android device (or emulator) only, it will not work on editor or on another platform; make sure you checked the Use Custom Build and Godot Ad Mob options in the export window.

so are have you done that ?

Biri0 commented 4 years ago

image this?

kamyabnazari commented 4 years ago

@BirioGames yes that is right and have you configured your AndroidManifest.xml cause:

every time you install a new version of the Android Build Template this step must be done again, as the AndroidManifest.xml file will be overridden.

and also the custom build compiles without any problem right?

Biri0 commented 4 years ago

yes, I added the app ID to the AndroidManifest.xml file

kamyabnazari commented 4 years ago

Alright, I will create a new sample project and test the problem at hand, I will let you know what the problem is. I will send you the project details as images inside of this issue.

kamyabnazari commented 4 years ago

Ok, I have tested it and it works on my side.

  1. Try to get the demo project first and test on that
  2. Do the Setup process as stated and add your App ID to your manifest <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-55555555555~111111111"/> between
    <manifest>
    <application>
    here
    </application>
    </mainfest>

Just try the Demo project first, if it does work. then it has something to do with the way your Godot project is setup.

I have created both my own project and used the demo project and both work.

Biri0 commented 4 years ago

The project I tested is a demo project with only one scene and the AdMob node. I added the app ID in the last line before

kamyabnazari commented 4 years ago

On what AVD are you testing?

Can you send the AndroidManifest.xml (make up your id while you send it) and also the project.godot?

Biri0 commented 4 years ago

i am using smartphone

project.godot:

; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
;   [section] ; section goes between []
;   param=value ; assign values to parameters

config_version=4

_global_script_classes=[ {
"base": "Node",
"class": "AdMob",
"language": "GDScript",
"path": "res://admob-lib/admob.gd"
} ]
_global_script_class_icons={
"AdMob": "res://admob-lib/icon.png"
}

[android]

modules="org/godotengine/godot/GodotAdMob"

[application]

config/name="Test"
run/main_scene="res://Scenes/Test.tscn"
config/icon="res://icon.png"

[rendering]

quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_environment="res://default_env.tres"

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.godot.game"
    android:versionCode="1"
    android:versionName="1.0"
    android:installLocation="auto" >

    <!-- Adding custom text to the manifest is fine, but do it outside the custom USER and APPLICATION BEGIN/END comments, -->
    <!-- as that gets rewritten. -->

    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true" />

    <!-- glEsVersion is modified by the exporter, changing this value here has no effect. -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

<!-- Custom user permissions XML added by add-ons. It's recommended to add them from the export preset, though. -->
<!--CHUNK_USER_PERMISSIONS_BEGIN-->
<!--CHUNK_USER_PERMISSIONS_END-->

    <!-- Any tag in this line after android:icon will be erased when doing custom builds. -->
    <!-- If you want to add tags manually, do before it. -->
    <!-- WARNING: This should stay on a single line until the parsing code is improved. See GH-32414. -->
    <application android:label="@string/godot_project_name_string" android:allowBackup="false" tools:ignore="GoogleAppIndexingWarning" android:icon="@mipmap/icon">

        <!-- The following metadata values are replaced when Godot exports, modifying them here has no effect. -->
        <!-- Do these changes in the export preset. Adding new ones is fine. -->

        <!-- XR mode metadata. This is modified by the exporter based on the selected xr mode. DO NOT CHANGE the values here. -->
        <meta-data
            android:name="xr_mode_metadata_name"
            android:value="xr_mode_metadata_value" />

        <!-- Metadata populated at export time and used by Godot to figure out which plugins must be enabled. -->
        <meta-data
            android:name="plugins"
            android:value="plugins_value"/>

        <activity
            android:name=".GodotApp"
            android:label="@string/godot_project_name_string"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            android:launchMode="singleTask"
            android:screenOrientation="landscape"
            android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
            android:resizeableActivity="false"
            tools:ignore="UnusedAttribute" >

            <!-- Focus awareness metadata populated at export time if the user enables it in the 'Xr Features' section. -->
            <meta-data android:name="com.oculus.vr.focusaware" android:value="oculus_focus_aware_value" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

<!-- Custom application XML added by add-ons. -->
<!--CHUNK_APPLICATION_BEGIN-->
<!--CHUNK_APPLICATION_END-->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-5287427620073213~1132750202"/>

    </application>

</manifest>
kamyabnazari commented 4 years ago

remove this line from project.godot:

[android]

modules="org/godotengine/godot/GodotAdMob

and start again. This plugin load through the custom android template and not as godot module.

I have recreated the problem and that seems to be the problem.

so delete that line from your project.godot file and it should work 👍

Biri0 commented 4 years ago

thanks! it works perfectly

kamyabnazari commented 4 years ago

Awesome have fun and good luck with your project 👍