AndroidPit License Fehler NPE while binding to App Center License Service

  • Antworten:4
Ben Becker
  • Forum-Beiträge: 209

07.11.2011, 22:08:56 via Website

Hiho!
Ich versuche in meine App dien Licences Dienst von AndroidPit mit einzubauen. Leider klappt das aber nicht. :(
Ich bekomme bei jedem 2. Aufruf folgenden Fehler:
111-07 22:06:20.803: I/AndroidPitLicenseChecker(32309): applicationError invoked; code = ERROR_COMMUNICATING_WITH_APPCENTER_0113; msg = NPE while binding to App Center License Service
211-07 22:06:20.811: E/AndroidPitLicenseChecker(32309): NPE while binding to App Center License Service
311-07 22:06:20.811: E/AndroidPitLicenseChecker(32309): java.lang.NullPointerException
411-07 22:06:20.811: E/AndroidPitLicenseChecker(32309): at de.androidpit.licensing.AndroidPitLicenseChecker$CheckLicenseThread.checkLicense(AndroidPitLicenseChecker.java:333)
511-07 22:06:20.811: E/AndroidPitLicenseChecker(32309): at de.androidpit.licensing.AndroidPitLicenseChecker$CheckLicenseThread.run(AndroidPitLicenseChecker.java:288)

Was bedeutet das?

Noch einweiteres Problem, beim zweiten Start ist die App "gekauft" auch wenn ich auf not licensed stelle. :(
11-07 22:19:48.960: I/AndroidPitLicenseChecker(506): License check returned LICENSED
11-07 22:19:48.975: I/LICENSE(506): allow

Was mache ich falsch?

1public abstract class LicenseCheckActivity extends TabActivity {
2
3 static boolean licensed = true;
4 static boolean didCheck = false;
5 static boolean checkingLicense = false;
6 static final String BASE64_PUBLIC_KEY = "KEY";
7 static final String ANDROIDPIT_PUBLIC_KEY="KEY";
8 private IAndroidPitLicenseCheckerCallback mLicenseCheckerCallback;
9 private AndroidPitLicenseChecker mChecker;
10
11 Handler mHandler;
12
13 SharedPreferences prefs;
14
15 // REPLACE WITH YOUR OWN SALT , THIS IS FROM EXAMPLE
16 private static final byte[] SALT = new byte[]{
17 ZAHLEN
18 };
19
20 private void displayResult(final String result) {
21 mHandler.post(new Runnable() {
22 public void run() {
23
24 setProgressBarIndeterminateVisibility(false);
25
26 }
27 });
28 }
29
30 protected void doCheck() {
31
32 didCheck = false;
33 checkingLicense = true;
34 setProgressBarIndeterminateVisibility(true);
35
36 mChecker.checkAccess(mLicenseCheckerCallback);
37 }
38
39 protected void checkLicense() {
40
41 Log.i("LICENSE", "checkLicense");
42 mHandler = new Handler();
43
44 // Try to use more data here. ANDROID_ID is a single point of attack.
45 String deviceId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
46
47 // Library calls this when it's done.
48 mLicenseCheckerCallback = new MyLicenseCheckerCallback();
49 // Construct the LicenseChecker with a policy.
50 mChecker = new AndroidPitLicenseChecker(
51 this,
52 getPackageName(),
53 ANDROIDPIT_PUBLIC_KEY,
54 new ServerManagedPolicy(
55 this,
56 new AESObfuscator(SALT, getPackageName(), deviceId)),
57 BASE64_PUBLIC_KEY);
58
59// mChecker = new LicenseChecker(
60// this, new StrictPolicy(),
61// BASE64_PUBLIC_KEY);
62
63 doCheck();
64 }
65
66 protected class MyLicenseCheckerCallback implements IAndroidPitLicenseCheckerCallback {
67
68 public void allow() {
69 Log.i("LICENSE", "allow");
70 if (isFinishing()) {
71 // Don't update UI if Activity is finishing.
72 return;
73 }
74 // Should allow user access.
75 displayResult(getString(R.string.allow));
76 licensed = true;
77 checkingLicense = false;
78 didCheck = true;
79
80 }
81
82 public void dontAllow() {
83 Log.i("LICENSE", "dontAllow");
84 if (isFinishing()) {
85 // Don't update UI if Activity is finishing.
86 return;
87 }
88 displayResult(getString(R.string.dont_allow));
89 licensed = false;
90 // Should not allow access. In most cases, the app should assume
91 // the user has access unless it encounters this. If it does,
92 // the app should inform the user of their unlicensed ways
93 // and then either shut down the app or limit the user to a
94 // restricted set of features.
95 // In this example, we show a dialog that takes the user to Market.
96 checkingLicense = false;
97 didCheck = true;
98
99 runOnUiThread(new Runnable() {
100 public void run() {
101 showDialog(0);
102 }
103 });
104 }
105
106 public void applicationError(AndroidPitLicenseCheckCode errorCode) {
107 Log.i("LICENSE", "error: " + errorCode);
108 if (isFinishing()) {
109 // Don't update UI if Activity is finishing.
110 return;
111 }
112 licensed = false;
113 // This is a polite way of saying the developer made a mistake
114 // while setting up or calling the license checker library.
115 // Please examine the error code and fix the error.
116 //String result = String.format(getString(R.string.application_error), errorCode);
117 checkingLicense = false;
118 didCheck = true;
119
120 //displayResult(result);
121 runOnUiThread(new Runnable() {
122 public void run() {
123 showDialog(0);
124 }
125 });
126 }
127 }
128
129 protected Dialog onCreateDialog(int id) {
130 // We have only one dialog.
131 return new AlertDialog.Builder(this)
132 .setTitle(R.string.unlicensed_dialog_title)
133 .setMessage(R.string.unlicensed_dialog_body)
134 .setPositiveButton(R.string.buy_button, new DialogInterface.OnClickListener() {
135 public void onClick(DialogInterface dialog, int which) {
136 Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
137 "http://market.android.com/details?id=" + getPackageName()));
138 startActivity(marketIntent);
139 finish();
140 }
141 })
142 .setNegativeButton(R.string.quit_button, new DialogInterface.OnClickListener() {
143 public void onClick(DialogInterface dialog, int which) {
144 finish();
145 }
146 })
147
148 .setCancelable(false)
149 .setOnKeyListener(new DialogInterface.OnKeyListener(){
150 public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
151 Log.i("License", "Key Listener");
152 finish();
153 return true;
154 }
155 })
156 .create();
157
158 }
159
160 @Override
161 protected void onDestroy() {
162 super.onDestroy();
163 if (mChecker != null) {
164 Log.i("LIcense", "distroy checker");
165 mChecker.onDestroy();
166 }
167 }
168
169}

— geändert am 07.11.2011, 22:22:01

Antworten
Jörg Jahnke
  • Forum-Beiträge: 5

30.01.2012, 22:28:49 via Website

Ich habe das gleich Problem. Irgendwelche Hinweise wie es zu lösen ist?

Antworten
Rafael K.
  • Forum-Beiträge: 2.359

31.01.2012, 10:05:17 via Website

Hast du das AppCenter installiert?
Wenn installiert: Vielleicht der Service gekillt?
Die AndroidPIT LVL läuft nur mit installiertem AppCenter, weil das AppCenter einen Service bereitstellt, über den dein AndroidPIT Account abgefragt wird und die von dir gekauften Apps ermittelt werden können.

Antworten
Jörg Jahnke
  • Forum-Beiträge: 5

31.01.2012, 22:39:08 via Website

App Center ist installiert. Inzwischen konnte ich entdecken, dass beim zweiten Aufruf alles klappte. Evtl. also ein Timing-Problem - was ich aber auch ein wenig bedenklich finde.

Antworten