Tag Archives: android

NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/scheme/SchemeRegistry;

When the Android project is running on Android 9.0, it will flash back and report the following error

Java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/scheme/SchemeRegistry;

terms of settlement:

Add the

<uses-library android:name="org.apache.http.legacy" android:required="false" />

Contribution by aizier River

Android Run App Warning: The application could not be installed: INSTALL_FAILED_TEST_ONLY

1. Questions

The newly installed Android studio (version 3.5.2) in the notebook runs the simplest program. The error prompt is as follows

The application could not be installed: INSTALL_FAILED_TEST_ONLY

2. Analysis

The Android manifest.xml file in advanced Android studio is as follows by default

android:testOnly="true"

3. Solutions

I tried to install with the following command and failed

adb install -t app-debug.apk

Then I tried to add the following to androidmanifest. XML, and it failed

android:testOnly="false"

Finally, I set the gradle. Properties global configuration in the project as follows, and then it runs successfully.

android.injected.testOnly=false

Another way is to build APK (s) directly in as

Build->Build Bundle(s)/Apk(s)-> Build Apk(s)

Android Error: open failed: EACCES (Permission denied)

When using Android to read SD card data, an error is reported. The reason is that after Android 6.0, in addition to adding read and write permissions in androidmanifest.xml, you also need to manually request permissions when using it.

1. Add read and write permissions to androidmanifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

2. To manually request permission before reading or writing:

import android.support.v4.app.ActivityCompat;

private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
    Manifest.permission.READ_EXTERNAL_STORAGE,
    Manifest.permission.WRITE_EXTERNAL_STORAGE
};

/**
 * Call this method before reading or writing to the sd card
 * Checks if the app has permission to write to device storage
 * If the app does not has permission then the user will be prompted to grant permissions
 */
public static void verifyStoragePermissions(Activity activity) {
    // Check if we have write permission
    int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if (permission != PackageManager.PERMISSION_GRANTED) {
        // We don't have permission so prompt the user
        ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
    }
}

Note: activitycompat is the method in android-support-v4.jar.

Failed to install APK, error code: install_ FAILED_ INVALID_ Apk solution

Development environment: Android studio

After copying a project, the package name and application ID are modified. After further development of the program, it is found that it cannot be installed on the mobile phone. The error code is: installation failed with message failed to finalize session:INSTALL_ FAILED_ INVALID_ Apk, as shown in the figure below:

It’s a big headache. There will be no error when copying the project (for copying and modifying the project in Android studio, please refer to: http://blog.csdn.net/Lone1yCode/article/details/79087495 )

Crazy Baidu found a very effective way, as shown in the following figure:

As shown in the figure above, on Android studio, click file, settings, build, execution, deployment, debugger and instant run, cancel the check and try to install again. It’s successful!!

The function of instant run is to speed up the construction and reconstruction. When running the program for the first time, the speed is the same as the normal speed. However, after making many modifications to the program, if you run the program again, Android studio will quickly complete the construction, which is much faster than running the program for the first time. You can learn more about Baidu by yourself.

In addition, I can only copy the project, and the running program will give this error prompt. If the edited project is not copied, it is recommended to start instant run.

Android Studio Error: Failed to delete some children. This might happen because a process has files open

   the error in build APK (s) is as follows:

Unable to delete directory 'F:\AndriodStudioProjects\EDM\app\build\outputs\apk\debug'
  Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
  - F:\AndriodStudioProjects\EDM\app\build\outputs\apk\debug\app-debug.apk

solution: close the folder of \… \ app/build/outputs/APK/debug

Error occurred when Android connected to cloud MySQL: java.lang.NoClassDefFoundError : Failed resolution of: Ljava/sql/SQLType

The error information is as follows:

E/AndroidRuntime: FATAL EXCEPTION: Thread-4
    Process: com.example.NCEPU, PID: 19597
    java.lang.NoClassDefFoundError: Failed resolution of: Ljava/sql/SQLType;
        at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:746)
        at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1170)
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447)
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
        at java.sql.DriverManager.getConnection(DriverManager.java:580)
        at java.sql.DriverManager.getConnection(DriverManager.java:218)
        at com.example.NCEPU.Utils.MySQLUtil$1.run(MySQLUtil.java:20)
        at java.lang.Thread.run(Thread.java:929)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "java.sql.SQLType" on path: DexPathList[[zip file "/data/app/com.example.NCEPU-ONfkLzQBKVHb0mVXKR3p5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.NCEPU-ONfkLzQBKVHb0mVXKR3p5g==/lib/arm64, /data/app/com.example.NCEPU-ONfkLzQBKVHb0mVXKR3p5g==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64, /hw_product/lib64, /system/product/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:746) 
        at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1170) 
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447) 
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) 
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) 
        at java.sql.DriverManager.getConnection(DriverManager.java:580) 
        at java.sql.DriverManager.getConnection(DriverManager.java:218) 
        at com.example.NCEPU.Utils.MySQLUtil$1.run(MySQLUtil.java:20) 
        at java.lang.Thread.run(Thread.java:929) 
W/libEGL: EGLNativeWindowType 0x6f3882b950 disconnect failed
I/Process: Sending signal. PID: 19597 SIG: 9

Problem analysis: the jar package version of MySQL is too high</ Font> I originally used the latest version: mysql-connector-java-8.0.21.jar

Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://your ip:port/dbname?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
connection = DriverManager.getConnection(url, user, password);

Problem solving: the jar version is a little lower. Here I use mysql-connector-java-5.1.49.jar downloaded from the official website. Note that after changing to the lower version, the loading driver should change to:

Class.forName("com.mysql.jdbc.Driver");

[Soloved] Gradle sync failed: Failed to open zip file

        After the as project is opened, an error is reported as follows:
Gradle sync failed: Failed to open zip file.
Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
Consult IDE log for more details (Help | Show Log) (216 ms)

The reason is that the network was disconnected during the last compilation, resulting in incomplete resource download. Open the gradle/wrapper/gradle of the project- wrapper.properties File, view the distributionurl of the current project, find the corresponding version, and then go to the setting (not the project) – build, execution,… – gradle, gradle user home of as to find the directory under the folder, Delete the folder of the corresponding version.

The perfect solution for China’s inability to access Google

Overseas Google servers continue to be blocked, all other Google services except CN domain names are inaccessible, and HK Google search is also unavailable. This blocking is different from the previous DNS domain name pollution attacks, which are intermittent. Most of Google’s server IP addresses are blocked by routing this time, and they have enjoyed the same level of treatment as Facebook and twitter.

China is the only country in the world that completely blocks Google. Russia and the United States are pinching each other so hard on the Ukraine issue, and they have not seen Russia block Google, have they?Of course, some people say that North Korea is not accessible. I have nothing to say about the big LAN in North Bangzi. In a word, Google’s failure to access it normally has brought us huge losses. Google Earth, Google map, Gmail, Google disk and Google play are scrapped Cause unnecessary trouble to millions of ordinary users, APP application developers and web developers

Well, we can’t control what the country does. Let’s talk about how to solve this problem. Let’s say hello first. I know it. Just use it quietly. I don’t publicize it or advocate it. Low key to longevity

Google as the world’s largest industry, mirror servers all over the world, tens of thousands of IP addresses, there are always fish out of the net. The following is a list of the IP addresses of Google servers that can still communicate normally (updated on January 21, 2015)

64.233.167.165 (effective) 64.233.167.164 (effective) 64.233.167.163 (effective) 64.233.167.166 (effective) 209.116.186.197 ~ 209.116.186.249 (effective) 91.213.30.150 (effective) 173.194.72.31 (dead)

Thanks to Google’s massive image servers, we don’t need to build a ladder. We just need to change the hosts of the computer to access Google normally.

Windows system hosts file location: open C/Windows/system32/Drivers/etc/

Android system hosts file location: system/etc/hosts

MAC system hosts file location/etc/hosts

Use Notepad to open the hosts file, copy and paste the following into hosts.

209.116.186.241 www.google.com #Google homepage 209.116.186.241 www.google.com.hk #Google Hong Kong homepage 209.116.186.241 ajax.googleapis.com #Google Ajax service 209.116.186.241 fonts.googleapis.com #Google font service 209.116.186.241 accounts.google.com #Google account login 209.116.186.241 plus.google.com #Google component 209.116.186.241 mail.google.com #Google email 209.116.186.241 maps.google.com #Google maps 209.116.186.241 play.google.com #Google App market 209.116.186.241 www.gstatic.com #Google static resources 209.116.186.241 apis.google.com #Google API service 209.116.186.241 ajax.googleapis.com #Google API server Ajax service 209.116.186.241 fonts.googleapis.com #Google API server font service 209.116.186.241 clients5.0 google.com #Google attachment # please follow www.mesk.cn Get the latest hosts rule 209.116.186.241 clients2 google.com #Google attachment 209.116.186.241 clients1 google.com #Google attachment 209.116.186.241 clients3 google.com #Google attachment 209.116.186.241 clients 4 google.com #Google attachment 209.116.186.241 oauth.googleusercontent.com #Google User Content 209.116.186.241 ssl.gstatic.com #Google static resources 209.116.186.241 www.gstatic.com #Google static resources 209.116.186.241 talkgadget.google.com #Google email 209.116.186.241- attachment.googleusercontent.com #Google email 209.116.186.241 chatenabled.mail.google . com # Google email 209.116.186.241 fonts.gstatic.com #Google static resource font 209.116.186.241 tools.google.com #Google Tools 209.116.186.241 translate.google.com . HK # Google translation 106.10.199.11 www.tianying888.com #Flickr

After saving, let’s try again. Can we access Google search, map, email, account login and other services normally!

Secondly, many Google fans have set up Google search images, such as the following websites

http://www.opengg.cn/ , http://www.qingpingseo.com/ , https://a26.d.akamai.net/f/1/1/1/dci.download.akamai.com/35985/159415/1/g/

Finally, let’s talk about it https://sinaapp.co/ This website, which calls itself the official image of Google (actually, I think this website has bright colors and is not official. Google’s principle is not to interfere in politics). This website is parasitic in foreign cloud computing, and it is impossible for the authorities to block the IP segment of these large service providers, so it can be accessed normally in the past.

When it comes to this website, there is another episode. Because its domain name is very similar to Sina cloud computing, when the firewall blocks the domain name, Sina cloud computing is also blocked, and then when it unsealed Sina, the domain name is also unsealed. You can imagine the operation mode of the firewall.

Appendix: duration of Google being blocked

Gmail: blocked since December 25, 2014

Google search, Google maps, Google play, etc.: blocked since May 31, 2014

Google collaboration platform: blocked since October 11, 2009

Picasa online album: blocked since July 16, 2009