Android SDK sources : Source code does not match bytecode - java

SDK versions:
compile SDK version : 27
target SDK version : 27
min SDK version : 23
Samsung tablet SDK version : 25 (Android 7.1.1)
I have sources installed for SDK version 25 and 27, but when stepping into SDK code I get an error "Byte code doesn't match source code". The source file opened is for SDK version 25.
This only happens for some android modules (android.widget, android.app) while others work fine (android.os).
The app source also contains some legacy and deprecated features.
Is there a way to
a) Find out what causes the mismatch or
b) Switch to decompiled source code

Its better to restart your android studio and make a clean fixed it for me

Related

NativeScript: Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later [duplicate]

I've installed NativeScript and I try to do tns platform add android but it doesn't work. ANDROID_HOME path is correct and I have installed SDK (API 22 and the newest one) and tools (25.0.2). When I run tns doctor it says:
WARNING: The Android SDK is not installed or is not configured properly.
Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=25.0.2'.
You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.
The current version of NativeScript 2.5.2 requires certain tools to be in the Android home directory so that it can detect them. The newest version of Android SDK (Mar 2017) actually removed the primary android support file and moved several binary files into other directories to clean things up.
Unfortunately this causes NativeScript to not be able to detect that you have the SDK. This version of the SDK came out AFTER the current version of NativeScript.
The simplest way to fix this that I can think of is to start from the command line; sdkmanager then choose to download the older 25.2.3 tools.
To manually do this; you would need to delete everything in your sdk/tools folder and download:
https://dl.google.com/android/repository/tools_r25.2.3-windows.zip (Windows)
https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip (Macintosh)
https://dl.google.com/android/repository/tools_r25.2.3-linux.zip (Linux)
Then extract these into that sdk/tools directory.
I solved this using the SDK manager in Android Studio, having already installed it previously, install all the requirements, namely
tools,platform-tools,android-25,build-tools-25.0.2,extra-android-m2repository,extra-google-m2repository,extra-android-support
Once installed change your ANDROID_HOME environment variable to point to this SDK manager. Typically, it will be at (/Users//Library/Android/sdk)
export ANDROID_HOME=/Users/<user_name>/Library/Android/sdk
Confirm that NativeScript detects your changes by running
tns doctor

no ManiActivty.java, acticity_main.xml, nor R.java ( when creating new android application project )

When I tried to create a new android application project, it didn't create ManiActivty.java, acticity_main.xml, nor R.java (there's only BuildConfig.java on the gen package)
and the AndroidManifest is like this:
http://i.stack.imgur.com/r8mIR.png
I've tried almost everything (checked that the Android Private Libraries and Android Dependencies in the java build path are checked, deleted gen and cleaned the project, restarting eclipse, reinstalling eclipse, tried with different Minimum Required SDK(with or without appcompat_v7) , but NONE of these were useful...
My ADT version is updated.
On the SDK manager I installed:
Android SDK tools Rev. 24
Android SDK Platform-tools Rev. 21
Android SDK Build-tools Rev. 21.1.1
Android 4.0 (API 14)
Android Support Repository Rev. 9
Android Support Library Rev.21.0.2 (also tried to reinstall it 2 times)
Google Repository Rev. 14
Google USB Driver Rev. 11
Windows 7 (64-bit)
and I have the latest version of java, and eclipse version: Luna Service Release 1 (4.4.1)
please help.
Please note that ADT is no longer officially updated. Instead of solving this particular problem, I would suggest switching to Android Studio (which is now version 1.0) for stability and support.
And to be less official - leave ADT alone, it is outdated and will cause you more problems in the future. As an experienced developer I strongly encourage you to switch to Android Studio, you will not regret. Also, you may still use your existing SDK files with Studio, you won't have to download all this again :-)

Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 14

So i recently switched the target of my android project to 4.0. Now i have practically errors on every line and the error "Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 14" on the console. So my question is, how do i change this to work with api 14 and compile? thanks.
If you're supporting API levels < 19 (4.4)
In eclipse:
Right click your project -> properties -> from the side bar, pick "Java Compiler" and then change Compiler compliance level to 1.6
If you're support API levels >= 19
You shouldn't see this issue. If you do, make sure that your project's minSdkVersion is properly configured.
I disagree with #Eran, this error cause by setting Project build target to 4.0 (API 14). If change to Java 1.6, you'll can't use Java 1.7 sode style, for ex: ArrayList myArrayList = new ArrayList<>();.
To fix this, set your target to 4.4 (API 19) or higher.
Below steps solved error in my Eclipse project
Go to android project
right click on the project
select properties
There is a option named 'Android' in right side menu
Select higher level API then API 14 or any other API that's installed in you SDK manager
and you're done.

Rebuild project for lower sdk/jdk. Failure [INSTALL_FAILED_OLDER_SDK]

I have an android project which was build under jdk 1.7. I have all 4+ and 2.1 -2.3 sdk packages in my InteilJ enviroment. All the time the project was tested under jdk 1.7, and v4.0++ emulator. Now I want to run it on device with 2.3.5 android api version but it responds with Failure [INSTALL_FAILED_OLDER_SDK] . I downloaded older jdk 1.6 and set 2.3 api for project. Even it passes rebuilding, the project can't start on real device. I've set minSdkVersion in manifest. When I start new project with above settings it works on this 2.3.5 device. Any ideas, sollution ?
Unfortunately, the installation failure error messages are not easy to understand in all cases.
[INSTALL_FAILED_OLDER_SDK] means that the minimum API level of the APK you are trying to install (android:minSdkVersion) is higher than the API level of the device you are trying to install it on.
In your case, a normal Android 2.3.5 device will report that it runs API Level 10. I say "normal", because a vendor firmware or ROM mod could report that it runs API Level 3, or API Level 1337, though usually the API level is not tinkered with this way.
In your case, it would appear that the manifest of the project has an android:minSdkVersion of 11 or higher. There is nothing wrong with that... except that the app will refuse to install on Android 1.x/2.x devices and emulators.

IntelliJ IDEA 12 - Incompatible Android version error

I'm starting out Android development with IntelliJ IDEA 12.0.
I have installed and configured JDK and Android SDK. I wanted to target Android SDK 2.3.3 so the SDK is configured as in the screenshot.
When I try and run the project though, I'm getting the following error:
android-validator: [untitled] Incompatible version of Android SDK Platform-tools package. Min version is 11. Please, update it though SDK manager
Followed by
android-validator: [untitled] Incompatible version of Android SDK Tools package. Min version is 19. Please, update it though SDK manager
I wasn't able to find any information on this and not sure what this means. Any pointers is appreciated.
--New project config--
--Install Android Packages--
android-validator: [untitled] Incompatible version of Android SDK
Platform-tools package. Min version is 11. Please, update it though
SDK manager
Because you have revision 10 and the IntelliJ IDEA tool needs revision 11
android-validator: [untitled] Incompatible version of Android SDK
Tools package. Min version is 19. Please, update it though SDK manager
Because you have revision 16 and the IntelliJ IDEA tool needs revision 19
The mentioned minimal revisions are requirements for IntelliJ IDEA to provide Android tools and to compile your applications. You should definitly launch again the Android SDK Manager and check the Tools folder, as on your screenshot, and click on "Install 2 packages".
I had the same issue. I updated "Android SDK Platform-tools" but it didn't work.
After that I realized that in the past I set c:\Android\android-sdk as the SDK folder. But the SDK manager was updating the folder named c:\Documents and Settings\my.user\Local Settings\Application Data\Android\android-sdk So IntelliJ was checking the old folder.
Problem solved after changing to right folder. So be sure that you set new folder if you have such issue. Check help documentation for setting the SDK folders: http://www.jetbrains.com/idea/webhelp/configuring-global-project-and-module-sdks.html

Categories