1
1
1nt3g3r2012-10-16 23:43:19
Java
1nt3g3r, 2012-10-16 23:43:19

Error while publishing Android app

I'm having the following problem: I have an application that consists of two related projects: the main one and the android port. I collect the port for android with ant, and I sign it with it. The apk file is normally created, when you drop this file on the device and run, the application installs and works normally. But when the application is published on Google Play, a message appears at startup about the unexpected termination of the program. logcat shows

mistake
10-16 10:21:49.059: E/AndroidRuntime(10140): FATAL EXCEPTION: main
10-16 10:21:49.059: E/AndroidRuntime(10140): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.fractal.labs.fruity.hunter.free/com.fractal.labs.fruity.hunter.free.FruityHunterActivity}: java.lang.ClassNotFoundException: com.fractal.labs.fruity.hunter.free.FruityHunterActivity in loader dalvik.system.PathClassLoader[/data/app/com.fractal.labs.fruity.hunter.free-1.apk]
10-16 10:21:49.059: E/AndroidRuntime(10140): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1680)
10-16 10:21:49.059: E/AndroidRuntime(10140): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
10-16 10:21:49.059: E/AndroidRuntime(10140): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
10-16 10:21:49.059: E/AndroidRuntime(10140): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
10-16 10:21:49.059: E/AndroidRuntime(10140): at android.os.Handler.dispatchMessage(Handler.java:99)
10-16 10:21:49.059: E/AndroidRuntime(10140): at android.os.Looper.loop(Looper.java:130)
10-16 10:21:49.059: E/AndroidRuntime(10140): at android.app.ActivityThread.main(ActivityThread.java:3835)
10-16 10:21:49.059: E/AndroidRuntime(10140): at java.lang.reflect.Method.invokeNative(Native Method)
10-16 10:21:49.059: E/AndroidRuntime(10140): at java.lang.reflect.Method.invoke(Method.java:507)
10-16 10:21:49.059: E/AndroidRuntime(10140): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
10-16 10:21:49.059: E/AndroidRuntime(10140): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-16 10:21:49.059: E/AndroidRuntime(10140): at dalvik.system.NativeStart.main(Native Method)
10-16 10:21:49.059: E/AndroidRuntime(10140): Caused by: java.lang.ClassNotFoundException: com.fractal.labs.fruity.hunter.free.FruityHunterActivity in loader dalvik.system.PathClassLoader[/data/app/com.fractal.labs.fruity.hunter.free-1.apk]
10-16 10:21:49.059: E/AndroidRuntime(10140): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
10-16 10:21:49.059: E/AndroidRuntime(10140): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
10-16 10:21:49.059: E/AndroidRuntime(10140): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
10-16 10:21:49.059: E/AndroidRuntime(10140): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
10-16 10:21:49.059: E/AndroidRuntime(10140): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
10-16 10:21:49.059: E/AndroidRuntime(10140):… 11 more


Here is the manifest
AndroidManifest.xml
<?xml version=«1.0» encoding=«utf-8»?>
<manifest xmlns:android=«schemas.android.com/apk/res/android»
package=«com.fractal.labs.fruity.hunter.free»
android:versionCode=«2»
android:versionName=«1.0» >

<uses-sdk android:minSdkVersion=«7» />
<uses-permission android:name=«android.permission.VIBRATE»/>
<uses-permission android:name=«android.permission.INTERNET»/>

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".FruityHunterActivity"
android:label="@string/app_name" android:screenOrientation=«landscape»>
<intent-filter>
<action android:name=«android.intent.action.MAIN» />

<category android:name=«android.intent.category.LAUNCHER» />
</intent-filter>





Here is the start activity class
FruityHunterActivity.java
package com.fractal.labs.fruity.hunter.free;

import java.util.Locale;

import android.os.Bundle;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.fractal.labs.fh.FrontController;

public class FruityHunterActivity extends AndroidApplication {
/** Called when the activity is first created. */
Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initialize(FrontController.getInstance(Locale.getDefault(), false, false), false);
}
}


Here is a cut from build.xml
<target name="build.free.nohd" depends="make.symlinks.free.nohd">
    <mkdir dir="${export.path}"/>
    <exec command="${android.command.dir}/android update project -p ${android.free.nohd}"/>
    <exec command="ant release" dir="${android.free.nohd}"/>
    <exec command="jarsigner -keystore ${keystore.name} -signedjar ${android.free.nohd.release}.noalign -storepass ${keystore.pass} -keypass ${alias.pass} ${android.free.nohd.nosign} ${alias.name}"/>
    <exec command="${android.command.dir}/zipalign -f -v 4 ${android.free.nohd.release}.noalign ${android.free.nohd.release}"/>
  </target>


Interestingly, everything worked fine before that, and it was uploaded and installed on google play without any problems. The build was done with Eclipse. Yes, and now everything works fine exactly until the moment it is uploaded to Google Play. That is, maybe google play somehow processes apk, and this needs to be taken into account somehow?

Another kind of small question. How to correctly name an activity in the manifest: .Activity, Activity, com.app.Activity? on the same StackOverflow they write different options, what is the difference between them.

Building an android project in Eclipse has any pitfalls? For example, in the case of building two related projects. I just added the line source.dir=../FruityHunterDesktop/src/com/ to ant.properties If anyone has experience building ant, please share examples of build.xml pieces.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin, 2012-10-17
@Norraxx

I had a similar error when I made a build for a pure android, and not for an android from Google. Check if all the libraries you are using are in the build (stupidly checkboxes in the project properties for libraries). And also check the package if the path is correct.
.Activity has the path "from package", com.path.Activity has the full path.

L
LeoCcoder, 2012-10-17
@LeoCcoder

do you use proguard? problems with loading classes arose a couple of times and all times were during experiments with the proguard ...

K
kristoft, 2015-12-08
@kristoft

java.lang.ClassNotFoundException occurs for various reasons. One of the most common is errors in dependencies, duplication of dependencies. I think it's worth digging in that direction. You can also try doing CLEAN

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question