パッケージ名でjsoupを使用してプレイストアでバージョン名を取得しようとしています。 prograudを有効にしてビルドapkを生成するとき。パッケージ名を取得中にエラーをスローします。私は "getActivity()。getPackageName()"でproguardを有効にしている間にクラッシュしていますが、有効にしなくてもうまく動作します
私はこのコードを使用して、プレイストアからバージョン名を取得しています。
@Override
protected String doInBackground(Void... params) {
String newVersion = null;
try {
Log.e("newVersion","newVersion");
newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + getActivity().getPackageName() + "&hl=it")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get()
.select("div[itemprop=softwareVersion]")
.first()
.ownText();
Log.e("Jsoup.connect","Jsoup.connect");
return newVersion;
} catch (Exception e) {
return newVersion;
}
}
と私のエラーは、次のとおりです。
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.iroid.android.gk4success_staffnurse, PID: 14673 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:318) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:762) Caused by: java.lang.ExceptionInInitializerError at org.a.b.i.a(Unknown Source) at org.a.b.i$b.<clinit>(Unknown Source) at org.a.b.f$a.<init>(Unknown Source) at org.a.b.f.<init>(Unknown Source) at org.a.c.l.b(Unknown Source) at org.a.c.l.a(Unknown Source) at org.a.c.b.a(Unknown Source) at org.a.c.f.a(Unknown Source) at org.a.a.a.a(Unknown Source) at org.a.a.b$c.e(Unknown Source) at org.a.a.b.a(Unknown Source) at com.iroid.android.gk4success_staffnurse.f.a$9.a(Unknown Source) at com.iroid.android.gk4success_staffnurse.f.a$9.doInBackground(Unknown Source) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:762) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.Reader.read(char[])' on a null object reference at java.util.Properties$LineReader.readLine(Properties.java:435) at java.util.Properties.load0(Properties.java:354) at java.util.Properties.load(Properties.java:342) at org.a.b.i.d(Unknown Source) at org.a.b.i.<clinit>(Unknown Source) at org.a.b.i.a(Unknown Source) at org.a.b.i$b.<clinit>(Unknown Source) at org.a.b.f$a.<init>(Unknown Source) at org.a.b.f.<init>(Unknown Source) at org.a.c.l.b(Unknown Source) at org.a.c.l.a(Unknown Source) at org.a.c.b.a(Unknown Source) at org.a.c.f.a(Unknown Source) at org.a.a.a.a(Unknown Source) at org.a.a.b$c.e(Unknown Source) at org.a.a.b.a(Unknown Source) at com.iroid.android.gk4success_staffnurse.f.a$9.a(Unknown Source) at com.iroid.android.gk4success_staffnurse.f.a$9.doInBackground(Unknown Source) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:762)
誰もがこのエラーを解決する方法を教えてくださいことはできますか?
おかげで多くのことを追加してみてください。今働いている。 –
申し訳ありません友人upvoteしようとしましたが、私の評判はあまりありません。 –