NoClassDefFoundError: com.microsoft.windowsazure.mobileservices.MobileServiceAuthenticationProvider - android

Iam making an android app which will authenticate a user into an active directory. Currently, I have followed a tutorial on http://www.windowsazure.com/en-us/documentation/articles/mobile-services-android-get-started-users/.
I only need to authenticate a user at this point. So I have done the following:-
import com.microsoft.windowsazure.mobileservices.MobileServiceApplication;
import com.microsoft.windowsazure.mobileservices.MobileServiceAuthenticationProvider;
import com.microsoft.windowsazure.mobileservices.MobileServiceClient;
import com.microsoft.windowsazure.mobileservices.MobileServiceUser;
import com.microsoft.windowsazure.mobileservices.ServiceFilterResponse;
import com.microsoft.windowsazure.mobileservices.UserAuthenticationCallback;
public static MobileServiceClient mobileServiceClient;
public MobileServiceUser _user;
MobileServiceClient mCLient;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
web = (WebView)findViewById(R.id.webSignin);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("https://login.microsoftonline.com/login.srf?wa=wsignin1%2E0&rpsnv=2&ct=1390811289&rver=6%2E1%2E6206%2E0&wp=MBI&wreply=https%3A%2F%2Fwww7679%2Esharepoint%2Ecom%2F%5Flayouts%2F15%2Flanding%2Easpx%3FSource%3Dhttps%253A%252F%252Fzevenseascom%252D11%252Esharepoint%252Eemea%252Emicrosoftonline%252Ecom%252F%255Fforms%252Fdefault%252Easpx&lc=16393&id=500046&guests=1");
authenticate();
}
private void authenticate()
{
// TODO Auto-generated method stub
mCLient.login(MobileServiceAuthenticationProvider.Google, new UserAuthenticationCallback()
{
#Override
public void onCompleted(MobileServiceUser user, Exception exception,
ServiceFilterResponse response)
{
// TODO Auto-generated method stub
if(exception == null)
{
createAndShowDialog(String.format("You are now logged in - %1$2s", user.getUserId()),"Success");
Intent myIntent = new Intent(MainActivity.this, Directory.class);
startActivity(myIntent);
}
else
{
createAndShowDialog("You must log in. Login Required", "Error");
}
}
});
}
But i get the following error:-
java.lang.NoClassDefFoundError: com.microsoft.windowsazure.mobileservices.MobileServiceAuthenticationProvider
01-28 10:34:04.732: E/AndroidRuntime(2150): at com.example.activedirectory.MainActivity.authenticate(MainActivity.java:68)
Any help is appreciated

Please init for MobileServiceClient mCLient; You just declare, not init. May be it is
mClient = new MobileServiceClient(...);
And with error:
-01-28 11:56:50.974: E/AndroidRuntime(6793):
java.lang.NoClassDefFoundError: com.google.gson.GsonBuilder 01-28 11:56:50.974: E/AndroidRuntime(6793): at com.microsoft.windowsazure.mobileservices.MobileServiceClient.createMobileServic‌​eGsonBuilder(MobileServiceClient.java:136) 01-28 11:56:50.974:
E/AndroidRuntime(6793): at com.microsoft.windowsazure.mobileservices.MobileServiceClient.<init>(MobileServi‌​ceClient.java:187)
just add library: GSON

Have you tried this solution.
Project Properties>Java Build Path>Order and Import tab and check the libraries you are using.
It seems that ADT update 22, you have to do this manually: Libraries do not get added to APK anymore after upgrade to ADT 22.

Related

Android Facebook Login Sdk: getActivity().getCallingActivity() returns null from their LoginFragment.class

I'm using the facebook-sdk for the facebook login button. This the facebook library I'm using:
implementation ('com.facebook.android:facebook-android-sdk:4.0.0'){
exclude group: 'com.android.support'
}
This is the crash raised by Firebase Crashlytics:
https://i.stack.imgur.com/jqArL.png
On this devices:
Galaxy S7 not rooted Android 7.0
Huawei Honor 9(STF-L09) not rooted Android 8.0
I check the code to know what is the Facebook library doing but I didn't find anything that I can do from my code to solve it. This is the method that raised the crash(LoginFragment.java line 68):
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
loginClient = savedInstanceState.getParcelable(SAVED_LOGIN_CLIENT);
loginClient.setFragment(this);
} else {
loginClient = new LoginClient(this);
}
callingPackage = getActivity().getCallingActivity().getPackageName();
request = (LoginClient.Request)
getActivity().getIntent().getParcelableExtra(EXTRA_REQUEST);
loginClient.setOnCompletedListener(new LoginClient.OnCompletedListener() {
#Override
public void onCompleted(LoginClient.Result outcome) {
onLoginClientCompleted(outcome);
}
});
}
This is the getCallingActivity method that returns null from android.app.Activity.java
public ComponentName getCallingActivity() {
try {
return ActivityManager.getService().getCallingActivity(mToken);
} catch (RemoteException e) {
return null;
}
}
I cannot reproduce the error with the testing devices at the office so I only have the Crashlytics report to solve it. I 'm clueless because it seems to work for most of the devices
Any help would be amazing, thanks in advance

Windows Azure Service Client

I'm trying the my Azure Mobile Service. Below is the code to make a new ToDo item entry. The sample Android code shows how to create a mobile client. I added it to the onCreate method as mentioned in the example.
But the insert always fails. I always get an exception which says com.microsoft.windowsazure.mobileservices.MobileServiceException: Error while processing request.
mClient does get initialized. But, mClient.mCurrentUser is null. Not sure if this is a problem.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
mClient = new MobileServiceClient("https://myservice.azure-mobile.net/",
"slkerjasfi234eSomePrivateKey", this);
Item item = new Item();
item.setText("Awesome item");
item.setComplete(false);
mClient.getTable(Item.class).insert(item,
new TableOperationCallback<Item>() {
public void onCompleted(Item entity,
Exception exception,
ServiceFilterResponse response) {
if (exception == null) {
ShowMessage("Success");
} else {
ShowMessage("Failed");
}
}
});
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
In my case, it looked like the key (parameter 2 in MobileServiceClient constructor) was incorrect. That is how I had downloaded it though. It happened again today and I manually fixed the key and it worked for another service. Believe it was the same issue here. To view your key, you go to your service in Azure and click Manage Keys at the bottom.

Google Play Game Services & libGDX "SignInActivity must be started with startActivityForResult"

I'm trying to implement Google Play Game Services into my libGDX game. I followed the tutorial here: http://helios.hud.ac.uk/u1070589/blog/?p=202
When my game loads, I create a new GameHelper object and call its setup method. I've debugged this part and it completes without any problems. I've placed a GPGS button on my main menu, when it's clicked I call the Login() method in my main Android Activity.
At this point the mConnectionResult.startResolutionForResult(mActivity, RC_RESOLVE) call in the resolveConnectionResult method (GameHelper class) returns the error:
E/SignInActivity(21930): SignInActivity must be started with startActivityForResult
The ConnectionResult object (mConnectionResult) doesn't have a public method available called startActivityForResult so I can't just change the startResolutionForResult call.
In the beginUserInitiatedSignIn() method (GameHelper) the connection returns ConnectionResult.SUCCESS. When resolveConnectionResult() is called, mConnectionResult.hasResolution() also returns true.
I've double-checked that my debug key matches the entry for my app in the Google APIs Console. I've checked that my app ID matches the one shown on the Google Play Developer Console.
I have managed to get the Type-a-Number example app working without any problems. Here's my main Android activity:
package com.eb.droid;
import android.content.Intent;
import android.view.Window;
import android.view.WindowManager;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.swarmconnect.Swarm;
import com.eb.GoogleInterface;
import com.google.example.games.basegameutils.GameHelper;
import com.google.example.games.basegameutils.GameHelper.GameHelperListener;
public final class AndroidGame extends AndroidApplication implements GameHelperListener, GoogleInterface
{
private final int RC_RESOLVE = 5000, RC_UNUSED = 5001; //request codes we use when invoking an external activity
private final SwarmData swarmData = new SwarmData();
private GameHelper aHelper;
public AndroidGame()
{
aHelper = new GameHelper(this);
aHelper.enableDebugLog(true, "MYTAG");
}
public final void onCreate(android.os.Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
// Disable hardware functions to save battery power.
cfg.useAccelerometer = false;
cfg.useCompass = false;
cfg.useGL20 = true;
aHelper.setup(this);
setSwarmKeyPartA();
initialize(new Game(this, swarmData), cfg);
// Activate Swarm if user is already logged-in. App won't nag player to log-in, they always have to
// do it manually via the Swarn dashboard via the title screen.
//Log.d(LOG, "onCreate() Swarm.isLoggedIn() = " + Swarm.isLoggedIn());
if (Swarm.isLoggedIn())
{
Swarm.setActive(this);
}
}
public void onResume()
{
super.onResume();
if (Swarm.isLoggedIn())
{
Swarm.setActive(this);
Swarm.init(this, swarmData.swarmAppID, swarmData.swarmAppKey);
}
}
public void onPause()
{
super.onPause();
Swarm.setInactive(this);
}
#Override
ublic void onStart()
{
super.onStart();
aHelper.onStart(this);
}
#Override
public void onStop()
{
super.onStop();
aHelper.onStop();
}
#Override
public void onActivityResult(int request, int response, Intent data)
{
super.onActivityResult(request, response, data);
aHelper.onActivityResult(request, response, data);
}
public void onSignInFailed()
{
System.out.println("sign in failed");
}
public void onSignInSucceeded()
{
System.out.println("sign in succeeded");
}
public void Login()
{
try
{
runOnUiThread(new Runnable()
{
#Override
public void run()
{
aHelper.beginUserInitiatedSignIn();
}
});
}
catch (final Exception ex)
{
}
}
public void LogOut()
{
try
{
runOnUiThread(new Runnable()
{
#Override
public void run()
{
aHelper.signOut();
}
});
}
catch (final Exception ex)
{
}
}
public boolean getSignedIn()
{
return aHelper.isSignedIn();
}
public void submitScore(int _score)
{
System.out.println("in submit score");
aHelper.getGamesClient().submitScore(getString(R.string.leaderboard_high_scores), _score);
}
public void showAchievements()
{
startActivityForResult(aHelper.getGamesClient().getAchievementsIntent(), RC_UNUSED);
}
public void showLeaderboards()
{
startActivityForResult(aHelper.getGamesClient().getAllLeaderboardsIntent(), RC_UNUSED);
}
public void getScoresData()
{
}
}
My app also currently implements Swarm, as can be seen in the Activity. I tried removing Swarm to see if that was negatively affecting the GPGS login, but still no luck.
I had the same issue, then I noticed this in the logs: "Activity is launching as a new task, so cancelling activity result"
In the AndroidManifest.xml file of my libgdx game, I had set this property: 'android:launchMode="singleInstance"' As soon as I removed that, I was able to use GPGS just like the sample apps.
I haven't looked at your code in detail. Basically I used the supplied GameHelper (I think you have done the same) and I put everything I needed from BaseGameUtils in my fragments. I suggest you look at a successful trace from TypeANumber to see what you are missing. Here is one of my traces:
07-04 10:21:54.511: D/ian_(1781): MultiTab3 beginUserInitiatedSignIn
04 10:21:54.531: D/ian_(1781): isGooglePlayServicesAvailable returned 0
07-04 10:21:54.531: D/ian_(1781): beginUserInitiatedSignIn: continuing pending sign-in flow.
07-04 10:21:54.611: D/ian_(1781): resolveConnectionResult: trying to resolve result: C onnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{40f3ed38: android.os.BinderProxy#40ee3de0}}
07-04 10:21:54.611: D/ian_(1781): result has resolution. Starting it.
07-04 10:21:54.621: D/ian_(1781): startResolutionForResult - this may be prob ?
07-04 10:23:29.480: D/ian_(1781): MultiPlayer onActivityResult called9001-1null
07-04 10:23:29.520: D/ian_(1781): MultiPlayer passing onActivityResult to MultiTab3 Req/Resp/Data=9001-1null
07-04 10:23:29.520: D/ian_(1781): MultiTab3 onActivityResult - passing through to GameHelper ...9001-1null
07-04 10:23:29.520: D/ian_(1781): onActivityResult, req 9001 response -1
07-04 10:23:29.520: D/ian_(1781): responseCode == RESULT_OK. So connecting.
07-04 10:23:30.130: D/ian_(1781): onConnected: connected! client=1
07-04 10:23:30.130: D/ian_(1781): All clients now connected. Sign-in successful.
07-04 10:23:30.130: D/ian_(1781): All requested clients connected. Sign-in succeeded!
Update:
What about this - is this just a copy and paste error or is your program missing the "P" on Public ? (You do need to make this call)
#Override
ublic void onStart()
{
super.onStart();
aHelper.onStart(this);
}
Update 2:
Based on the work you have done, you have now eliminated the possibility of a programming error. I have not seen a setup error that caused this problem. However I did encounter this which is (sort of) similar:
onConnectionFailed: result 4
onConnectionFailed: since user initiated sign-in, trying to resolve problem
statusCode=SIGN_IN_REQUIRED resolution=PendingIntent
result has resolution. Starting it.
Explanation from google docs "The client attempted to connect to the service but the user is not signed in"
n.b. Google setting is showing that we are signed in as ..........#gmail.com
further investigation **suggests** that this may be because of a set up problem in the
google play api console and/or google play developer console ...
I also notice that you mentioned the Google API console. I suggest you create a new set of definitions in the Developer Console and that you do not make any amendments through the API console. I am not saying that you have changed things in the API console - I just think it is easier at this point to create a new set of definitions and (I'm repeating myself I know) don't make any changes through the API console.

PayPal.initWithAppID() crashes with NullPointerException

FATAL EXCEPTION: Thread-5195
java.lang.NullPointerException: src == null
at java.lang.System.arraycopy(Native Method)
at com.paypal.android.a.g.a(Unknown Source)
at com.paypal.android.a.h.c(Unknown Source)
at com.paypal.android.MEP.PayPal.setLanguage(Unknown Source)
at com.paypal.android.MEP.PayPal.initWithAppID(Unknown Source)
at com.lonfun.pets.UnityPayMenuActivity.initLibrary(UnityPayMenuActivity.java:256)
at com.lonfun.pets.UnityPayMenuActivity.access$2(UnityPayMenuActivity.java:249)
at com.lonfun.pets.UnityPayMenuActivity$2$1.run(UnityPayMenuActivity.java:175)
I just use android to open paypal, everything is ok, but if I call from unity, this is happened!
this is my java code:
package com.paypal.androidpets;
import android.content.Context;
import android.os.Handler;
import com.lonfun.pets.UnityPayMenuActivity;
import com.paypal.android.MEP.PayPal;
import com.paypal.android.MEP.PayPalActivity;
public class PaypalTool {
Context context;
PayPal pp;
private static final int server = PayPal.ENV_SANDBOX;
// The ID of your application that you received from PayPal
private static final String appID = "APP-80W284485P519543T";
public PaypalTool(Context context) {
this.context=context;
}
public void initLibrary(final Handler handler)
{
new Thread() {
public void run() {
PayPalActivity._paypal = null;
pp = PayPal.getInstance();
// If the library is already initialized, then we don't need to initialize it again.
if(pp == null) {
// pp = PayPal.initWithAppID(context, "", PayPal.ENV_NONE);
pp = PayPal.initWithAppID(context, appID, server);
pp.setShippingEnabled(false);
}
if (PayPal.getInstance().isLibraryInitialized()) {
handler.sendEmptyMessage(0);
}
else {
handler.sendEmptyMessage(1);
}
}
}.start();
}
}
has anybody solve this problem,,please help me, thank you!
using UnityEngine;
using System.Collections;
public class PayMoneyHandler : MonoBehaviour
{
#if UNITY_ANDROID
static AndroidJavaClass payPluginClass;
static AndroidJavaClass unityPlayer;
static AndroidJavaObject currActivity;
#endif
public static void Pay(string productID)
{
#if UNITY_ANDROID
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
jo.Call("StartActivity0",
"com.peten.tier2",
"EGAHCNJDEJBWBIBWEXIKDEGLJECOAD.Mac",
"Dog",
"AndDogCn",
"http://42.121.94.123/TradeWeb/AlipayTrade.aspx",
"http://58.246.188.238/TradeWeb/PaypalTrade.aspx"
);
#endif
}
}
using UnityEngine;
using System.Collections;
public class TestForPaypal : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void OnClick(){
Debug.Log("Test For Paypal!");
PayMoneyHandler.Pay("test1");
}
}
public void StartActivity0(final String name,final String PlayerName,final String GameID,final String ZoneID,final String payUrl,final String paypalUrl)
{
this.runOnUiThread(new Runnable() {
#Override
public void run() {
Log.i("Order", "name:"+name+"PlayerName:"+PlayerName+"GameID:"+GameID+"ZoneID:"+ZoneID+"payUrl:"+payUrl+"paypalUrl:"+paypalUrl);
Intent payintent=new Intent(mContext,UnityPayMenuActivity.class);
payintent.putExtra("name",name);
payintent.putExtra("PlayerName",PlayerName);
payintent.putExtra("GameID",GameID);
payintent.putExtra("ZoneID",ZoneID);
payintent.putExtra("payUrl",payUrl);
payintent.putExtra("paypalUrl",paypalUrl);
Unity3DMainActiviy.this.startActivity(payintent);
}
});
}
I think you didnot enter the appID and the server detail.
Below is the working code which i have implement and It works fine for me.
I have implement Pay on button click which extends the runnable
Check_out.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (_paypalLibraryInit) {
showPayPalButton();
//Toast.makeText(Android_PP_Test1Activity.this, captions[position], Toast.LENGTH_SHORT).show();
}
else {
// Display a progress dialog to the user and start checking for when
// the initialization is completed
Thread initThread = new Thread(initLibraryRunnable);
initThread.start();
_progressDialog = new ProgressDialog(Recharge.this);
_progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
_progressDialog.setMessage("Loading PayPal Payment Library");
_progressDialog.setCancelable(false);
_progressDialog.show();
_progressDialogRunning = true;
Thread newThread = new Thread(checkforPayPalInitRunnable);
newThread.start();
//Toast.makeText(Android_PP_Test1Activity.this, "Picasso Paintings", Toast.LENGTH_SHORT).show();
}
}
});
This button call this runnable method
//This lets us run the initLibrary function
final Runnable initLibraryRunnable = new Runnable() {
public void run() {
initLibrary();
}
};
and this method is responsible to initiate the initLibrary.
/** init method **/
public void initLibrary() {
PayPal pp = PayPal.getInstance();
if (pp == null) {
// This is the main initialization call that takes in your Context,
// the Application ID, and the server you would like to connect to.
pp=PayPal.initWithAppID(this,"APP80W284485P519543T",PayPal.ENV_SANDBOX);
// -- These are required settings.
pp.setLanguage("en_US"); // Sets the language for the library.
// --
// -- These are a few of the optional settings.
// Sets the fees payer. If there are fees for the transaction, this
// person will pay for them. Possible values are FEEPAYER_SENDER,
// FEEPAYER_PRIMARYRECEIVER, FEEPAYER_EACHRECEIVER, and
// FEEPAYER_SECONDARYONLY.
pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER);
// Set to true if the transaction will require shipping.
pp.setShippingEnabled(true);
// Dynamic Amount Calculation allows you to set tax and shipping
// amounts based on the user's shipping address. Shipping must be
// enabled for Dynamic Amount Calculation. This also requires you to
// create a class that implements PaymentAdjuster and Serializable.
pp.setDynamicAmountCalculationEnabled(false);
// --
}
}
Hope It helps...
The problem is when unity generates the apk file. I have compared one apk i made miself with PayPal integration only compiling with eclipse and other compiling with Unity.
Lets say the apk i made only with eclipse is called "PayPalOnlyEclipse.apk" and the one made with unity "PayPalWithUnity.apk"; y renamed them to "PayPalOnlyEclipse.zip" and "PayPalWithUnity.zip", then open both with WinRar to compare them.
I found that PayPalOnlyEclipse had one folder that PayPalWithUnity didn't, the folder is "com\paypal\android\utils\data". So I decompressed that folder and then added it to PayPalWithUnity. Then erase the META-INF folder (the signing), then close the "PayPalWithUnity.zip" and rename it like it was before ("PayPalWithUnity.apk").
Then I used the command for signing the apk file:
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore my.keystore PayPalWithUnity.apk user
Finally I used the command for zipalign:
zipalign -v 4 PayPalWithUnity.apk PayPalWithUnity2.apk
that command generates PayPalWithUnity2.apk and that is the apk file you have to install in your phone.
Hope it helps, and sorry for my english.
Check if you have included the PaypalActivity on manifest file. Like this:
<activity android:name="com.paypal.android.MEP.PayPalActivity"
android:configChanges="keyboardHidden|orientation" />
If you have it and it doesnt work yet, include the library on the build path (Properties>>Java Buid Path>>Libraries>>Add JARs) and add it on the "order and export" tab (Properties>>Java Buid Path>>Order and Export).

noclassdeferror for inner class MyLicenseCheckerCallback

Im trying to do this tutorial
But keep getting this error:
08-21 14:12:49.599: E/AndroidRuntime(714):
java.lang.NoClassDefFoundError:
com.akiraapps.LicenseCheck$MyLicenseCheckerCallback
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings.Secure;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import com.google.android.vending.licensing.AESObfuscator;
import com.google.android.vending.licensing.LicenseChecker;
import com.google.android.vending.licensing.LicenseCheckerCallback;
import com.google.android.vending.licensing.Policy;
import com.google.android.vending.licensing.ServerManagedPolicy;
public class LicenseCheck extends Activity {
private static final String BASE64_PUBLIC_KEY = "no";
private static final byte[] SALT = new byte[] { no};
private TextView mStatusText;
private Button mCheckLicenseButton;
private LicenseCheckerCallback mLicenseCheckerCallback;
private LicenseChecker mChecker;
// A handler on the UI thread.
private Handler mHandler;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.main);
mStatusText = (TextView) findViewById(R.id.status_text);
mCheckLicenseButton = (Button) findViewById(R.id.check_license_button);
mCheckLicenseButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
doCheck();
}
});
mHandler = new Handler();
// Try to use more data here. ANDROID_ID is a single point of attack.
String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
// Library calls this when it's done.
mLicenseCheckerCallback = new MyLicenseCheckerCallback();
// Construct the LicenseChecker with a policy.
mChecker = new LicenseChecker(
this, new ServerManagedPolicy(this,
new AESObfuscator(SALT, getPackageName(), deviceId)),
BASE64_PUBLIC_KEY);
doCheck();
}
protected Dialog onCreateDialog(int id) {
final boolean bRetry = id == 1;
return new AlertDialog.Builder(this)
.setTitle(R.string.unlicensed_dialog_title)
.setMessage(bRetry ? R.string.unlicensed_dialog_retry_body : R.string.unlicensed_dialog_body)
.setPositiveButton(bRetry ? R.string.retry_button : R.string.buy_button, new DialogInterface.OnClickListener() {
boolean mRetry = bRetry;
public void onClick(DialogInterface dialog, int which) {
if ( mRetry ) {
doCheck();
} else {
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"http://market.android.com/details?id=" + getPackageName()));
startActivity(marketIntent);
}
}
})
.setNegativeButton(R.string.quit_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
}).create();
}
private void doCheck() {
mCheckLicenseButton.setEnabled(false);
setProgressBarIndeterminateVisibility(true);
mStatusText.setText(R.string.checking_license);
mChecker.checkAccess(mLicenseCheckerCallback);
}
private void displayResult(final String result) {
mHandler.post(new Runnable() {
public void run() {
mStatusText.setText(result);
setProgressBarIndeterminateVisibility(false);
mCheckLicenseButton.setEnabled(true);
}
});
}
private void displayDialog(final boolean showRetry) {
mHandler.post(new Runnable() {
public void run() {
setProgressBarIndeterminateVisibility(false);
showDialog(showRetry ? 1 : 0);
mCheckLicenseButton.setEnabled(true);
}
});
}
private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
public void allow(int policyReason) {
System.out.println("Allow");
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
// Should allow user access.
displayResult(getString(R.string.allow));
}
public void dontAllow(int policyReason) {
System.out.println("dontAllow");
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
displayResult(getString(R.string.dont_allow));
// Should not allow access. In most cases, the app should assume
// the user has access unless it encounters this. If it does,
// the app should inform the user of their unlicensed ways
// and then either shut down the app or limit the user to a
// restricted set of features.
// In this example, we show a dialog that takes the user to Market.
// If the reason for the lack of license is that the service is
// unavailable or there is another problem, we display a
// retry button on the dialog and a different message.
displayDialog(policyReason == Policy.RETRY);
}
public void applicationError(int errorCode) {
System.out.println("applicationError");
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
// This is a polite way of saying the developer made a mistake
// while setting up or calling the license checker library.
// Please examine the error code and fix the error.
String result = String.format(getString(R.string.application_error), errorCode);
displayResult(result);
}
}
#Override
protected void onDestroy() {
super.onDestroy();
mChecker.onDestroy();
}
}
I follow the tutorial for setting up LVL as a library project and those imports seem to be ok.
Why do I get this error? Why can it not find the inner class? If I right click and say show definition it jumps to the inner class.
I had same problem.
Below steps solved the probelm
take standard library example
coppied the library.jar file from the library project into your libs folder
So this SO Answer is what fixed it
I created a folder called libs and coppied the library.jar file from the library project included in the licensing package downloaded with the manager
What I dont understand is per this answer this should have been done for me
As I am using ADT 20.0.3
Basically it comes down to an example that I downloaded directly from android and got stuck for a few hours trying to figure out what was wrong and this seems like this step should have been in the readme/help docs OR Im doing something wrong.
If you know why this is the answer and how to do it better please answer and Ill change the answer to yours.
I had the exact same exception and none of the above recommendations worked for me.
However I got mine working by ensuring that your LVL project is a library project (right click project -> properties -> android and tick the "Is Libary" checkbo).
To include this in your application project remove any other references to this and apply the changes. Then if not already there navigate to (right click application project --> properties --> android) and in the library section click Add and select your LVL project. Apply Changes. Ok and clean project.
Hope this helps someone.

Categories

Resources