Tag Archives: Android

ERROR Unsupported method AndroidProject.getVariantNames().

ERROR: Unsupported method: AndroidProject.getVariantNames
Problem: Error cause: Solution:

Question:
Recently, the company asked me to connect to the function of one-button confidential-free login, and I also need to be familiar with client development. After opening the project with Android Studio, I reported an error, which was as follows:

ERROR: Unsupported method: AndroidProject.getVariantNames().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.

Translation:
Error: doesn’t support method: AndroidProject GetVariantNames (). The Gradle version to which
is connected does not support this method.
to solve this problem, you can change/upgrade the target version of the Gradle that you connect to.
or, you can ignore this exception and read additional information from the model.
Solutions:

    modify the build.gradle file under the project directory
classpath "com.android.tools.build:gradle:3.3.2" 
    project./gradle/wrapper/gradle-wrapper. Properties, see the address link
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
    gradle sync once;

How to Fix Android Error:This Gradle plugin requires Studio 3.0 minimum

Today, I’ll continue a quick overview of how to resolve an Error:This Gradle Plugin requires Studio 3.0 minimum.
I’ve talked a little bit about this before, and it’s a little bit incomplete, so let me write it down again.Reason: The project USES version 3.0 and the computer installed version 2.2.2. The error report of the imported project Gradle

Solutions:
Solution a:
Build. Gradle

Instead of ‘com. Android. Tools. Build: gradle: 2.3.3’
Scheme 2:
Gradle. In the properties
Add android. Injected. Build. Model. Only the versioned = 3
If not, or continue to gradle. The properties file to add an android. Injected. TestOnly = false

Android :This Gradle Plugin requires Studio 3.0 minimum.

It’s that simple.

com.android.ddmlib.AdbCommandRejectedException: device offline Error while Installing APK (How to Fix)

com.android.ddmlib.AdbCommandRejectedException:device offline
Error while Installing APK

The problem is that ADB is killed, just restart it
There are three ways:
1. Plattform-tools can be found in the SDK file, and adb can be found in this folder.
Double-click ADB to restart it

Second, you can also perform a two-step command operation in CMD:
1, the adb kill server
2, the adb start – server

Restart the computer

— —
copyright notice: this article is the original article of CSDN blogger “shenshizhong”, in accordance with CC 4.0 by-sa copyright agreement, please attach the source link and this statement.

ERROR: Unsupported method: AndroidProject.getVariantNames().

The problemERROR: Unsupported method: AndroidProject. GetVariantNames ().
The version of Gradle you connect to does not support that method.
to resolve The problem you can change/upgrade The target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.

Translation:
Error: doesn’t support method: AndroidProject GetVariantNames ().
The Gradle version connected to does not support this method.
To resolve this problem, you can change/upgrade the target version of the Gradle you connect to.
Alternatively, you can ignore the exception and read additional information from the model.

methods

    1. modify the build.gradle file in the project directory,
classpath "com.android.tools.build:gradle:3.3.2"

In engineering./ Gradle/Wrapper/Gradle-wrapper. Properties, take a look at the address link

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

Gradle sync once;

reference
Relationship between Android Studio and Gradle

    https://developer.android.google.cn/studio/releases/gradle-plugin#updating-gradle

Eclipse:An error has occurred. See error log for more details. java.lang.NullPointerException

Problem description
In the use of Eclipse the Clean project times wrong: An error has occurred. See the error log for more details. Java. Lang. NullPointerException . Guess this is due to Eclipse not closing normally.

Open Eclipse log\workspace\.metadata\. Log as follows:

!ENTRY org.eclipse.jface 4 2 2019-04-25 15:42:06.381
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface".
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jst.jee.ui.internal.navigator.web.WebAppProvider.getImage(WebAppProvider.java:99)
	at org.eclipse.jst.jee.ui.internal.navigator.Web25LabelProvider.getImage(Web25LabelProvider.java:47)
	at org.eclipse.ui.internal.navigator.NavigatorContentServiceLabelProvider.findImage(NavigatorContentServiceLabelProvider.java:197)
	at org.eclipse.ui.internal.navigator.NavigatorContentServiceLabelProvider.getColumnImage(NavigatorContentServiceLabelProvider.java:105)
	at org.eclipse.ui.internal.navigator.NavigatorContentServiceLabelProvider.getImage(NavigatorContentServiceLabelProvider.java:98)
	at org.eclipse.ui.internal.navigator.NavigatorDecoratingLabelProvider$StyledLabelProviderAdapter.getImage(NavigatorDecoratingLabelProvider.java:59)
	at org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.getImage(DelegatingStyledCellLabelProvider.java:195)
	at org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider.getImage(DecoratingStyledCellLabelProvider.java:173)
	at org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.update(DelegatingStyledCellLabelProvider.java:121)
	at org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider.update(DecoratingStyledCellLabelProvider.java:136)
	at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:154)
	at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:949)
	at org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeRunnable.run(AbstractTreeViewer.java:114)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
	at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:1029)
	at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:472)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
	at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:2150)
	at org.eclipse.jface.viewers.StructuredViewer.internalUpdate(StructuredViewer.java:2133)
	at org.eclipse.jface.viewers.StructuredViewer.update(StructuredViewer.java:2071)
	at org.eclipse.jface.viewers.ColumnViewer.update(ColumnViewer.java:540)
	at org.eclipse.ui.navigator.CommonViewer.update(CommonViewer.java:535)
	at org.eclipse.jface.viewers.StructuredViewer.update(StructuredViewer.java:2015)
	at org.eclipse.jface.viewers.StructuredViewer.handleLabelProviderChanged(StructuredViewer.java:1182)
	at org.eclipse.ui.navigator.CommonViewer.handleLabelProviderChanged(CommonViewer.java:235)
	at org.eclipse.jface.viewers.ContentViewer$1.labelProviderChanged(ContentViewer.java:99)
	at org.eclipse.jface.viewers.BaseLabelProvider$1.run(BaseLabelProvider.java:72)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
	at org.eclipse.jface.viewers.BaseLabelProvider.fireLabelProviderChanged(BaseLabelProvider.java:69)
	at org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider$1.labelProviderChanged(DecoratingStyledCellLabelProvider.java:78)
	at org.eclipse.ui.internal.decorators.DecoratorManager$1.run(DecoratorManager.java:446)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.decorators.DecoratorManager.fireListener(DecoratorManager.java:443)
	at org.eclipse.ui.internal.decorators.DecorationScheduler$3.runInUIThread(DecorationScheduler.java:536)
	at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:97)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4147)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3764)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

The solution

    Delete the current item, be careful not to check this box: Delete project contents on disk (cannot be undone) re-import the item, project -- > Clean... So just a little bit of engineering will do

Some online methods
Try so start Eclipse from the console/terminal with the -clean option.
On Windows:
Eclipse.exe -clean
On Linux/Unix:
./eclipse -clean
or if Eclipse is in your PATH
eclipse -clean
This will clear your plug-ins cache, maybe it solves the issue.

Problems encountered by Android Studio: Session’app’: Error Installing APKs

With Android Studio, I was using real machine debugging, but failed. Notice the Error in the picture below (Session ‘app’ :Error APKS).
in general, there are several ways to solve this problem:
1. Recompile
2. Replug the data cable
3. Change the Studio Settings to uncheck the first check box below
4. Restart adb
1. Restart adb
Type adb kill-server on the command line
Then type ADB Devices
2. Restart adb. Exe
The task manager closes the adb.exe process
Then type ADB Devices on the command line

greendao insert data UNIQUE constraint failed: PURCHASE_ORDER_TABLE._id (code 1555)

On the face of it, I encountered this problem recently when the project was about to go live
In Greendao’s database table, the ID field is unique due to the insertion of data with duplicate IDS
However, our business logic is that if the database is emptied and the data is inserted, it is theoretically impossible to have duplicate ids

DaoUtils.getDaoSession().getPurchaseOrderTableDao().insertInTx(mPurSkuList);

The number of lines of code goes to this location
The first thing that comes to mind is that the data table may not be completely cleaned up, but after debugging, it is indeed completely cleaned up
Continue debugging and find problems

A strange upgrade data package error problem

As we all know, in Android system, APP upgrade or OTA package upgrade, we download the completed file from the background. After the download, we will check whether the file is downloaded properly and whether there is an error in the middle by checking whether the md5 and byte size match the package hung in the background server.
if the download is normal, we will go to the upgrade process; If download error, will go to delete the wrong file, download again.
general file download data error may be due to the network outage, re-breakpoint when the continuation of the cause.
Recently encountered a very tricky question,
phenomenon described as follows: the OTA updates after the download is complete, has passed the md5 check and file byte size, confirm the identity of the package and server backstage netting, software validation is completed, will soon enter the 5 s countdown prompt the user system update, at this time in the countdown screen immediately for manual power Android devices, the Android system reboot into recovery to upgrade, you will be prompted to upgrade package data corruption error; However, if the upgrade package is downloaded and the software is verified and passed, the power will be turned off again after a while, and the upgrade will be resumed normally.

Opening update package...
I:read key e=3 hash=20
I:1 key(s) loaded from /res/keys
Verifying update package...
E:footer is wrong
I:verify_file returned 1
E:signature verification failed
Installation aborted.

After communicating with colleagues who are maintaining Recovery, they said that this situation is usually caused by corrupted data of the downloaded upgrade package, or the file to be upgraded is not the upgrade package, which leads to Footer is wrong.
When checking this problem, the log found that both MD5 and file size verification of OTA upgrade package downloaded were correct. How could the packet be abnormal when upgrading after fast power failure?
but when the recovery report data is damaged, the data size of the upgrade package is indeed several M smaller than that of the complete upgrade package in the background. Moreover, the faster the power failure is after verification, the larger the difference between the upgrade package and the complete upgrade package will be in the next upgrade. If the power failure is slower, the difference will be smaller.

1. The upgrade package was not downloaded before power failure;
2. The download was completed before power off, and the packet was read and written again before power on and upgrade, resulting in data error.

immediately after the download of the upgrade package, the permission of the upgrade package is changed to ro read-only to see if the upgrade can be successful.
can be successfully upgraded, indicating that the upgrade package has been downloaded before the power failure is confirmed. Otherwise, it is concluded that the upgrade package data has not been downloaded.

download upgrade package after completion, upgrade package directory through ls-l command to see the file size is right, originally wanted to manually upgrade package permission chmod 400 *.zip, but found that the file operation is not, more weird;
power off, power on and upgrade through the upgrade package directory to see that there is still a few M missing.
can’t change the upgrade package property to read only.
How possible, clearly a file has been downloaded, and checked, boot after you said that the file is damaged, faint ~
After communication with colleagues, hold on, there is another possibility, even though the download is complete, although it’s been md5 checksum, although also match the file size, but through the command to read or software calibration data is not completely synchronized to the flash, because the data loss is related to the speed of power, haha ~
thought of this, the feeling is probably like this.
experiment immediately, before power off, manually execute sync command, found that the packet is normal after startup,
and sync action after completion, chmod 400 *.zip changed to read-only action can also be executed, it seems that the system did not fully synchronize the data to flash, at this time we are not allowed to change the file permissions.
experiments, found that all normal. I’m so excited
Finally, the software added protection for this situation,
after the file verification was completed, added the action of sync, which fixed this weird problem.

Android Studio sync build.gradle appears: Failed to resolve: com.android.support:appcompat problem

After initializing a project using Android Studio, you need to sync the app/build.gradle file, but it will report an error such as:

Failed to resolve: com.android.support:appcompat-v7:26.0.0

What is the reason for this?
If your Android SDK is greater than 26.0.0, you will need to add the following statements in build.Gradle in the root directory of your project:

...

allprojects {
    repositories {
        ...
        maven {
            url "https://maven.google.com"
        }
    }
}

...

Refer to the link
In addition, if it still doesn’t work, let’s see if the SDK version is correct. In app/build.gradle, there is a column of data that is buildToolsVersion, and we should write its SDK version

Android Studio error “Manifest merger failed with multiple errors, see logs” solution

Error:Execution failed for task 'XXX :processDebugManifest'. > Manifest merger failed with multiple errors, see logs
problem solution.

added a new item as a dependency to the original project today, after a series of configurations in the Manifest, this error occurs for gradle.
Why
The Gradle plug-in for AS enables the Manifest Merger Tool by default, and if the same attributes AS the main project are also defined in the Library project (such AS the default-generated Android:icon and Android: Theme), then the merge fails and the error is reported.
solution
In the manifest is joined on the root tag XMLNS: tools = "http://schemas.android.com/tools" , and in the manifest. The application of XML tags add tools: replace = "icon, label, the theme" (multiple attributes, separated, as the case may be). Or tools: replace = "the android: icon, android: label, android: theme"
http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger official method for reference

GoogleIO 2013 Android fast networking framework Volley introduction

Recently, I investigated the Android development framework, looked at XUtils, KjFramework and other frameworks of HTTP modules, I think it is too simple, but simply encapsulate HttpUrlConnenction and Handler, added a callback function, I feel it is better than to write a little bit. Later I found Volley, a relatively reliable Android network request framework, and used it.
Volley is the network communication library on the Android platform, making network communication faster, simpler, and more robust.
is the origin of Volley’s name: a burst or emission of many things or a large amount at once
in Google IO’s speech, the picture is a picture of firing arrows, which is similar to meteor.

in fact, from this picture, we can also see that Volley is particularly suitable for scenarios with small amounts of data but heavy communication.

GoogleIO2013 Android Quick Networking Framework Volley

 Features offered by Volley

Asynchronous download of JSON, images, etc..
Sorting of network requests (scheduling)
Prioritization of network requests
cache
Multi-level cancellation requests
Linkage to Activity and Lifecycle (simultaneous cancellation of all network requests at the end of Activity)