私はカスタムアプリケーションクラスのアンドロイドアプリを持っています。Androidアプリケーションダウンロードとインストール後のClassNotFoundException
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Utils.isThereUpdatedVersion(this);
}
}
isThereUpdatedVersion機能は、PHPのページがある尋ねます。私のアプリの新しいバージョンがあり、そこには新しいボタンをインストールするためのボタンが付いたボタンがあります。
私はアンドロイドを追加しました:私はAndroidのメーカーを通じて私のアプリを実行すると、私のマニフェスト
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".application.MyApplication">
に属性に名前を付け、アプリが完全に実行されています。私はそれをダウンロードしてインストールできる新しいバージョンがありますか?しかし、インストール後、私はアプリを開き、私はこのエラーが発生し、アプリケーションがクラッシュします。
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.andre_jacq_ing.preleveurgmail, PID: 2915
java.lang.RuntimeException: Unable to instantiate application com.andre_jacq_ing.preleveurgmail.application.MyApplication: java.lang.ClassNotFoundException: Didn't find class "com.andre_jacq_ing.preleveurgmail.application.MyApplication" on path: DexPathList[[zip file "/data/app/com.andre_jacq_ing.preleveurgmail-1/base.apk"],nativeLibraryDirectories=[/data/app/com.andre_jacq_ing.preleveurgmail-1/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:839)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5855)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.andre_jacq_ing.preleveurgmail.application.MyApplication" on path: DexPathList[[zip file "/data/app/com.andre_jacq_ing.preleveurgmail-1/base.apk"],nativeLibraryDirectories=[/data/app/com.andre_jacq_ing.preleveurgmail-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newApplication(Instrumentation.java:1000)
at android.app.LoadedApk.makeApplication(LoadedApk.java:828)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5855)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
誰かが私にこのことを教えてもらえますか?
編集は
私は私の.apkに私をリダイレクトし、私はこのコードを使用して自分のサーバー上のURL呼び出しています:あなたのパッケージ名が正しい場合は、あなたをきれいにしようとし、その後
URL url = new URL(arg0[0]);
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
int lenghtOfFile = c.getContentLength();
String PATH = "/mnt/sdcard/Download/";
File file = new File(PATH);
file.mkdirs();
File outputFile = new File(file, "app.apk");
if(outputFile.exists()){
outputFile.delete();
}
FileOutputStream fos = new FileOutputStream(outputFile);
InputStream is = c.getInputStream();
byte[] buffer = new byte[1024];
int count;
long total = 0;
while ((count = is.read(buffer)) != -1) {
total += count;
fos.write(buffer, 0, count);
publishProgress((int) (total * 100/lenghtOfFile));
}
fos.close();
is.close();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(outputFile), "application/vnd.android.package-archive");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // without this flag android returned a intent error!
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(intent);
パスが ".application.MyApplication"と一致していないようです。完全なパスを追加してから試してください。私はあなたのパッケージ名がこの "com.andre_jacq_ing.preleveurgmail"のようだと思うので、MyApplicationクラスの完全なパッケージパスを追加する必要があります –
既にフルパスで試してみて、同じエラーが発生しました – utiiz
どのようにアプリケーションをアップデートしていますか? – Ufkoku