1, the Android Studio to making: how to submit code blog.csdn.net/u011068702/…

2, Eclipse import android project package XML error not generated R file: jingyan.baidu.com/article/c91…

3, resolve the failure of WebView and JavaScript call confusion: add “keep all methods in this class unconfused” to Eclipse proguard. CFG

-keep public class com.example.web_01.WebHost
{
    public ;
}Copy the code

[1] create File in libs directory of project: Android-suppory-v4.jar. Properties [2] Add SRC = E:\ android to android-support-v4.jar SDK\ SDK\ Extras \ Android \support\v4\ SRC (SRC location of the corresponding version in SDK) [3] Restart Eclipse

5, GenyMotion [1] restart ADB method: Enter ADB kill-server and ADB start-server in CMD D:\android\adt-bundle-windows-x86_64-20140702\ SDK \platform-tools [2] Eclipse fails to recognize GenyMotion because genyMotion’s API version is lower than the project’s API version

ADB Server didn’t ACK: Open task Manager, click process, and end all mobile assistant processes in it. The reason was that the mobile phone assistant occupies the ADB port 5037, can under the platform – the tools with netstat ano | findstr searches “5037” to check.

Unable to resolve target ‘Android-17’ Change Project target.target=android-17 to Project target.target=android-21

V4 package cannot be found: If the jar package in the reference library is inconsistent with the JAR package of this project, the V4 package cannot be found. Optionally delete one of them so that the JARS in both projects are the same

Custom Application problem: A custom Application must be registered and obtained using the getApplication() method.

10, SQLite use problem: Java. Lang. An IllegalStateException: Couldn’t read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. Inconsistent fields. If you modify the database, uninstall the original application and then reinstall it. For field sorting, use TreeMap instead of HashMap.

11, Layout dynamic setting height:

/ / must use android. View. ViewGroup. LayoutParams resetting highly android. The ViewGroup. LayoutParams pp = the getLayoutParams (); pp.height = 200; view.setLayoutParams(pp);Copy the code

Add a judgment flag to onClickListener: view.settag ()

Android Sudio import Eclipse project: www.open-open.com/lib/view/op…

14. Solve the problem that the number of Android application methods cannot exceed 65K (from Android Bus Android Developer Portal):

As an Android developer, you've probably heard of the 65K limit on the number of Methods on Android, and as your application gets richer and richer, you'll eventually run into an exception:  Conversion to Dalvik format failed:Unable toexecute dex: method ID not in [0, 0xffff]: Some of you may say, it's easy to solve this problem, we just need to configure a sentence in Project. Proterty: Ok, dex.force.jumbo=true, yes, adding this sentence can actually make your application compile, But INSTALL_FAILED_DEXOPT can easily occur on some 2.3 machines! For the above two anomalies, let's first analyze the reasons: 1. In Android system, the method ID stored in a Dex file is of short type, so the method in your Dex cannot exceed 65K. 2. We cannot change the structure of the Android system at the application layer, so we cannot change the data type from short to int or other types. That is to say, the number of methods in a dex cannot exceed 65K, which is an unbridgeable gap. We can only reduce the number of methods in one dex. First of all, the most obvious solution is to get rid of some useless jars, and set some attributes to the public, which can remove the get/set methods, this method can only be a temporary solution, with the passage of time, or one day there will be a method of more than 65 k, after all, an application is in commonly add functionality, not lose function. Next, I will introduce two mainstream solutions. One is represented by wechat, which makes some functions into plug-ins and dynamically loads them; the other is a subcontract represented by Facebook, which divides the DEX file in an APK into multiple DEX files and dynamically loads the DEX file. In fact this two kinds of schemes of core idea is the same, is the future to develop new features make it apk and dex dynamic load, and the subcontract plan is to have the function of the complete dynamic load is divided into multiple dex file, personally I think plug-in solutions score package better solve the problem of 65 k, because the plugin scheme can not only solve the problem of 65 k, It also allows us to reduce the size of our application, whereas subcontracting can only solve the 65K problem. I wrote about the basic idea of plug-in development, making it dynamically loaded, a long time ago in an article, If you are interested, you can look at "Implementing Android Dynamic loading APK (Fragment or Activity implementation)". Below we will focus on the subcontracting mechanism. We know that there is a dex file in an APK file, and this dex file is optimized class file. The first dex is called main.dex and the second is called second.dex. Usually, when subcontracting, we need to put the classes needed for application startup into main.dex. For Android, it will only load main.dex by default. Second. Dex may be just a resource file for it, and it will not take the initiative to load Second. We need to create a class loader for second. Dex so that I can load the classes in second. Dex when I use them. There are many ways to load second.dex, and the main ones are as follows: 1. The simplest way is to use DexClassLoader to load, and set the parent loader of the DexClassLoader to PathClassLoader. And set the parent of DexClassLoader to the parent of PathClassLoader, Set the parent loader of PahtClassLoader to DexClassLoader, and taste the difference between 1 and 2. 3. Put the path of second. For example, when second. Dex is loaded by a DexClassLoader, but a class is used in Second. Dex, which is in main.dex, an exception will be raised if the class cannot be found. So this solution can only have second. Dex and does not use the main. Dex class. Build Android project based on Gradle and realize the subcontracting environment requirements: If your project is in Eclipse, then you need to import the project into Android. At this point, you need to upgrade your project to adT22. 3. Open the build.gradle file of a Moudle under your project. Added to the android - support - multidex. Jar of relying on 4, remove third-party jar package repeated class 5, set the virtual machine heap memory size, avoid OOM 6 during compilation, gradle build project, seems to be the default is not to add so library project, So to avoid this, we need to specify the so library directory and, for projects converted from Eclipse, the SRC and resource file paths. 7. Add multiDexEnabled = true and jnilibs. srcDirs =['libs'] to each library project. You can use MultiDexApplication in androidmanifest.xml. If your project has a custom Application that inherits from Application, you can use MultiDexApplication instead. If your project inherits other Applications, then you need to override attachBaseContext after the above configuration, your project should have been successfully subcontracted. If the subcontracting is successful, you will decompress your APK file and find two dex files. Through the above configuration process, we find that in this scheme we cannot control which classes are in main.dex and which classes are in second.dex. Through this scheme, subcontracting can be compatible with API4-API20. In the above scheme, since we can't see the script of gradle building projects, we have no control over which classes are in the first dex and which classes are in the second dex. In this solution, we use Ant to build. Ant allows users to define their own build scheme. For example, we can customize the build scheme by putting some third-party JAR packages in the project into second. Please refer to the open source project on https://github.com/mmin18/Dex65536.git since the project loaded second. Dex scheme is adopted by the above scheme 2, such as the second. Certain third-party jar package depends on the main in the dex. Dex in some classes, This solution will be implemented, so I will remove this solution and replace it with solution 3, which is to set the path of second. Dex to the loading path of PathClassLoader. I only give the solution in Android 4.4, other systems are similar to loading second. After the subcontracting is successful, unpack the APK file and enter the assert folder. Libs. apk is a dex file compiled by the third party JAR. The fundamental reason is that the memory of Dalvik VM before version 2.3 is only 5M, so some mobile phones will still encounter this problem no matter the plug-in scheme or the subcontract scheme. After all, we only reduced the number of packages in each dex, but the total number of methods did not. So the fundamental way to solve this problem is to modify the virtual machine memory to 8 m, the demand on the Java layer could not be achieved, but can be implemented in c layer and the concrete implementation process can reference source project: https://github.com/viilaismonster/LinearAllocFix.git. Some of the methods used in this method can be found in the Android-support-multidex. jar, but not all of them are posted here. !Copy the code

15, the problem of accessing the development API official website: use Firefox browser, set to work offline

16, binding Service related problems: in the Service of registration, to join the android: exported = “true”, otherwise it will generate Java. Lang. SecurityException: Not allowed to bind to the service Intent {act=www.qslx.com.aidl.IRemoteService, this error, is binding the service

Error findViewById caused by switching the order of XML layout controls in Eclipse development: Clean project

18, PopupWindow click outside will disappear solution:

setOutsideTouchable(true); SetBackgroundDrawable (new BitmapDrawable()); SetTouchInterceptor (new OnTouchListener() {@override public Boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { dismiss(); return true; } return false; }});Copy the code

19, getView() reuse problem: [1] reset state and then select state [2] use List or Bean to store state

20, click ListView Item no response: android: descendantFocusability = “blocksDescendants” www.cnblogs.com/eyu8874521/…

21, use network related problems: to import

Copy the code

Rather than

Copy the code

Note that the test phone is also connected to the Internet

22. Image loading location error caused by ListView control reuse: [1] Bind setTag() to imageView, and set image only when getTag() is the same in handler. [2] Cache variables passed by member variables to avoid errors caused by Thread

23, ListView image multiple loading problem: use LruCache

24, ListView sliding caton problem: 【 1 】 ListView sliding stop before loading visible item [2] the ListView sliding, cancel all add-in. [3] to achieve AbsListView OnScrollListener

Android :layout_above=”@+id/bottom”

Listview. setAdapter generates Null Pointer Exception:




Paste_Image.png

// Null Pointer Exception blinds because mDatas is Null mListView.setAdapter(new ListDirArrayAdapter(Context, mDatas));Copy the code

27, Java unsigned number usage:

Public static long getUnsignedIntt(long data) {// 0~4294967295 32 is an unsigned number // (0xFFFFFFFF is DWORD). return data & 0x00000000FFFFFFFFL; //L must not leak! !!!!! }Copy the code

28, string equals returns false: pay attention to case, can output comparison

29, Eclipse add project dependency error (solution same as 8): jar package inconsistent, delete one of them

Android Studio failed to import Module Gradle. [1] Modify the build.gradle file, Change compileSdkVersion, buildToolsVersion, minSdkVersion, targetSdkVersion to be the same [2] to modify the wrapper of gradle folder gradle – wrapper. The properties and modifying gradle – 2.4 – all.zip doc.okbase.net/x359981514/…

31, Failed to find target with hash string ‘Android-22’ : modify build.gradle compileSdkVersion and buildToolsVersion

32. SVN merge code conflict: [1] back up the code in advance [2] directly replace the SVN project folder with the backup code folder, and then Commit

33, UmENG or QQ open platform common problems: [2] Android :label=”@string/app_name” this app_name should be consistent with the application name when registered, such as QSLXDEMO




Paste_Image.png