[android-developers] Android app licensing error class not found
I have worked through the example in the SDK and am now receiving the following error when trying to run the demo app. Caused by: java.lang.ClassNotFoundException: Didn't find class "com.rythmair.licenseverification.MainActivity" on path: DexPathList[[zip file "/data/app/com.rythmair.licenseverification-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] Here is my full MainActivity package com.rythmair.licenseverification; 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;import android.util.Log;import android.view.View;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 MainActivity extends Activity { String tag = "LICENSE: "; private static final String BASE64_PUBLIC_KEY = "MY_KEY_REMOVED"; // Generate your own 20 random bytes, and put them here. private static final byte[] SALT = new byte[] { -46, 65, 30, -128, -103, -57, 74, -64, 51, 88, -95, -45, 77, -117, -36, -113, -11, 32, -64, 89 }; private TextView mStatusText; private Button mCheckLicenseButton; private LicenseCheckerCallback mLicenseCheckerCallback; private LicenseChecker mChecker; // A handler on the UI thread. private Handler mHandler; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.i(tag, "Just in onCreate method."); 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(); Log.i(tag, "Just set mHandler to new Handler."); // Try to use more data here. ANDROID_ID is a single point of attack. String deviceId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); // Library calls this when it's done. Log.i(tag, "Setting new mLicenseCheckerCallback"); mLicenseCheckerCallback = new MyLicenseCheckerCallback(); // Construct the LicenseChecker with a policy. Log.i(tag, "Setting mChecker variable."); 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() {
[android-developers] Am I missing a qualifier?
Hello all, I am continue to build my knowledge around Android design and could use some clarification. I am trying to understand how you can get two different sized devices which have the same dpi use two different image assets. I have built an application which has a significant number of res folders which use one or more resource qualifiers. For example, I have the following. drawable-sw320dp-mdpi drawable-sw320dp-xxhdpi drawable-sw800dp-mdpi layout-sw720dp-mdpi layout-sw720dp-xxxhdpi layout-sw800dp-mdpi I've had to do this in order to keep images in my application proportional from one screen size / density to the next. Here is where things are getting a bit rough. Take a phone that is listed at 768x1280, mdpi, 160dp. If I am understanding things correctly, this means the following. It is an mdpi device so 1px = 1dp The size of the device in dp is 768x1280 This device will use my layout in the layout-sw800dp-mdpi folder It should use the image asset that is in my drawable-sw800dp-mdpi folder Am I correct up to this point? Now, let's say I have a tablet, that is 2048 x 1536 (Galaxy Tab S2) and is mdpi. Does this mean that it will use the same layout and drawable resources as the previously mentioned phone? Does this also mean that the resource in my drawable folder should be as follows? dpi = 48 size (what fits my needs) Given this information is correct, I would expect that the single image of sizeX and dpi of 48 would look proportional on both devices, which unfortunately I am not always finding to be correct. If someone could tell me if I'm in the ball park or WAY off base on my understanding up to this point, I would really appreciate it. Thank you! Bob -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/fde4f66f-f9bd-4310-890e-93bb3c561100%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Android virtual device help
Hello all, I am looking to be able to test a wide variety of screens in Android studio and am wondering if someone could point me to a resource or provide some assistance? My goal is to be able to develop against the following. sw240dp... sw320dp-mdpi sw320dp-hdpi sw320dp-xhdpi sw320dp-xxhdpi sw320dp-xxxhdpi sw600dp-mdpi sw600dp-hdpi sw600dp-xhdpi sw600dp-xxhdpi sw600dp-xxxhdp8 ... the same for sw720dp I am guessing there are profiles you can download and load in to the AVD manager? Or do you need to build them manually? I have tried to setup a few of them but I am not fully understanding the AVD yet for getting new device definitions in to it. I am using this many qualifiers due to the fact that I have some images that I need to stay proportional between smaller and larger same density devices. Unfortunately, Androids scaling to ensure things stay the same size between a 3" phone and 10" tablet that both happen to have a dp of 320 is not helping me here. Thanks! Bob -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/50ec71e5-9ee4-4ebb-89d9-a78f2c3d1d47%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] SURELY, someone out there can help/explain this to me.
Hi all, (as you read through this) -- I am not hard coding ANY dimensions or sizes for anything -- All elements use wrap content and match parent -- I have read over the Android development for different screen sizes so many times I can almost recite the page (not to say I haven't missed something, so if I have, please point it out). I am literally on weeks of trying to figure this out and have read (many times) every resource I can find and am still clearly missing something. I am attempting to get image assets to stay in proportion to the screen on different devices. This seems very fundamental and there is tons of documentation, but I am still struggling and would greatly appreciate some assistance. I have created 5 sets of images which look like the following. ldpi - dpi of the images is 36 x 36 mdpi - dpi of the images is 48 x 48 hdpi - dpi of the images is 72 x 72 xhdpi - dpi of the images is 96 x 96 xxhdpi - dpi of the images is 144 x 144 I am designing in Android Studio and using one of the 10" xhdpi tablet devices to design against. I have a square image that I am placing 4 times (roughly evenly spaced) at the top of my screen and when viewing the screen, the image takes up roughly one inch or so. To accomplish this, I created an image that is 325x325px with a dpi of 96 and it looks fantastic. The problem comes when I try to view my app on smaller device with the same density of xhdpi. In these situations, the image is HUGE and takes up far more space than it should. I believe I understand the difference between pixel (tablet that is 1200 px x 800 px) and dip/dp. Given that the dimensions in pixels are 1200 x 800 and the density is xhdpi, the dimension in dp would be 600 x 400. This is where I am getting totally lost. Clearly I am missing something and there must be a way to keep images proportioned correctly when you go from a small device size to a larger device size when both use the same density (for example, a 800 pixel x 600 px 3" phone and a 2500 pixel x 1600 pixel 10" tablet which both have a density of xhdpi). I do also realize that this is only 1/2 of the equation and the use of additional layout folders with qualifiers will be needed to potentially make adjustments for different screen sizes. That part I am ok with but I am losing my mind over trying to figure out how to get my image assets to look the way I need. Any help would be OH so much appreciated. One final note. I have seen several posts where people have stated, "Just use xhdpi assets and Android will scale everything for you." Yes, I know this is a performance issue, but even trying that, it certainly is not scaling things down for me. One thing I have noticed is that if I set the background property of a layout to an image asset, it seems to display as I'd want on every device, regardless of size or density. However, the issue I am having is with image views specifically, so does my problem exist there? Thanks! Bob -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/d9c3d809-d511-4800-8234-bc2512b4869e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Missing something when sizing images to support different screens
I have been reading over this information, forums, developer site, etc. for the past week and still have been unsuccessful in fully understanding how to size images such that things appear acceptable on different sized devices. Certainly there is something I am missing, as this can't be that difficult, can it? If someone could please point me in the right direction, I would be ever so grateful. I am using qualifiers on the drawable and layout folders in an attempt to handle the various screen sizes and densities. I have created drawable-ldpi, drawable-mdpi, drawable-hdpi, and drawable-xhdpi I have created layout-w320dp, layout-w480dp, layout-w600dp, and layout-w720dp I have placed a copy of the layout I am dealing with in each of the layout folders so I can adjust each as needed. I have placed my graphics that I am testing with in their respective drawable folder. I initially designed my app using a Galaxy Tab 10" and scaled my graphics (png) files in GIMP with a dpi of 320 and sized to fit how I wanted them to look in the 10" environment. I then took the original graphic (unmodified) that was used for the previously mentioned image and made the mdpi version by changing the dpi to 160 and setting the pixel width/height to 1/2 of the previously mentioned image. For the rest, I followed the information from the design guide of... ldpi = .75 of the mdpi hdpi = 1.5 of the mdpi With the first image created being the xhdpi Question 1: Should you scale all images such that the following are true, regardless of the dimensions of each image? - ldpi images should always be 120dpi - mdpi images should always be 160dpi - hdpi images should always be 240dpi - xhdpi images should always be 320dpi Here is an example of what I have done and what specifically is not working. I have a logo that is 400 x 400 and has a dpi of 320. This image looks beautiful on my tablet and the image file resides in the xhdpi folder I then took a copy of this image and scaled it to 200 x 200 with a dpi of 160 for my mdpi version and placed the file in the mdpi folder. When viewing a 10" device in Android Studio, it looks great When viewing a phone 3-4" device in Android Studio, the logo in HUGE! My goal is basically this. If I have an image that takes up exactly 1/4 of my screen on a tablet in the lower left corner, I want that image to take up the same 1/4 of the screen on the smaller devices, not be huge, taking up pretty much the entire screen. Question 2: I thought Android was supposed to down-sample the images of larger than what was needed so it would essentially scale things down for me, with a better goal of providing assets that are close to where they should be, which is what I am attempting to do. Is this not the case? There has to be some formula / step that I am simply missing here so if anyone could shed some light on this for me, I would greatly appreciate it. Thank you all! Bob -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/390111ec-3b70-4668-8d35-a688a974fe26%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.