No resource found that matches the given name 'Theme.AppCompat.Light' - android

I am having problems setting up my eclipse program with Android for my first project. After installing eclipse together with the android developer tools, I tried to create a new 'Android Project' with a minimum sdk of Android 2.2, a target sdk of Android 6.0 and a sdk compiler of Android 7.1.1.
After clicking run, Eclipse displayed an error, which indicated that there was issues with my empty activity:
Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'
I have done my research for this problem and most of the solutions suggested importing an Android Project called "AppCompat-v7". However, upon selecting the file, there were no projects found that could be imported. This is what I see:
Import project window:
I have spent numerous hours trying to fix this issue. I have ensured that both my eclipse program and all android files are under the same hard disk, I have tried adding the file to the build path etc. but the same problem persists.
Anyone out there who can help me with this issue please? I would greatly appreciate it :) If you need more details regarding what I have done so far, feel free to contact me!
Someone commented below suggesting that I import the "AppCompat-v7" folder to the package explorer and then go to Project->Properties to add the appcompat library folder. I managed to add the folder to my package explorer but I am not able to add the library to the project, as no library options show up. This is even so after checking the "IsLibrary" box.

AppCompat-v7 should be added to your module Gradle file.
It goes in the dependencies section.
For example:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
}

if you have Appcompat v7 in your extras folder follow this link but if you don't have it:
To download the Support Library through the SDK Manager:
Start the Android SDK Manager.
In the SDK Manager window, scroll to the end of the Packages list, find the Extras folder and, if necessary, expand to show its contents.
Select the Android Support
Repository item. Click the Install packages... button.
After downloading, the tool installs the Support Library files to your existing Android SDK directory. The library files are located in the following subdirectory of your SDK: <sdk>/extras/android/m2repository/com/android/support/ directory.
Update: Import it like this picture
you are now have your library in your project Explorer like this
the rest is adding library project

Related

Should i Import appcompact_v7 to android studio

I'm porting from eclipse to android studio, do I need to import appcompat_v7 from my existing eclipse project into android studio?
As stated in Android's Support Library Overview, it is considered good practice to include the support library by default because of the large diversity of devices and the fragmentation that exists between the different versions of Android (and thus, of the provided APIs).
This is the reason why Android code templates tools included in Android Studio through the Android Development Tools (ADT) integrate them by default.
An example would be the ability of using the Fragment API which appears on API 11 (Android 3.0 Honeycomb) on a device that runs an older version of this system. Or the newer RecyclerView which was introduced in API 21 (Android 5.0 Lollipop) can be used on pre-lollipop devices with the user of appcompact.
It is also to be noted that you can deactivate automatic inclusion of the Support Library by default.
To import a project to Android Studio:
Start Android Studio and close any open Android Studio projects.
From the Android Studio menu select File > New > Import Project.
Select the Eclipse ADT project folder with the AndroidManifest.xml file and click Ok.
Select the destination folder and click Next.
Select the import options and click Finish.
The import process prompts to migrate any library and project dependencies to Android Studio, and add the dependency declarations to the build.gradle file. The import process also replaces any well-known source libraries, binary libraries, and JAR files that have known Maven coordinates with Maven dependencies, so you no longer need to maintain these dependencies manually. The import options also allow you to enter your workspace directory and any actual path maps to handle any unresolved relative paths, path variables, and linked resource references.
Android Studio imports the app and displays the project import summary. Review the summary for details about the project restructuring and the import process.
After importing the project from Eclipse ADT to the new Android Studio project and module structure, each app module folder in Android Studio contains the complete source set for that module, including the src/main and src/androidTest directories, resources, build file, and Android manifest. Before starting app development, you should resolve any issues shown in the project import summary to make sure the project re-structuring and import process completed properly.
The process is changed frequently so the text above will probably be outdated very soon whilst the link below will be updated so the link is you're best bet. The link also provides pictures to help aid the process.
https://developer.android.com/sdk/installing/migrate.html
You should be written your build.gradle file.
This is script.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1' //Support Library
}

Auto link source code downloaded by Gradle

Sorry if this question is duplicated but I have searched for a while and couldn't find the answer.
I use Android Studio and Gradle to develop my app, gralde will auto download source code from maven but then inside Android Studio it's said that "Sources Not Found" and I have to drag drop or select the source files directly. This is very troublesome. Is there anyway that AS auto link the sources downloaded with the class, and when I ctrl + click on the class it will open the source file directly?
Edit: Some libraries like ButterKnife I can view source code directly, but others like MaterialEditext I have to select the source file manually.
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.rengwuxian.materialedittext:library:2.0.3'
ButterKnife can be found in External Library while MaterialEditext isn't. I don't know why.
Not every module you want can be selected automatically. Only those you can find in dependencies could be imported by Gradle. Take a look here:right-click at your project --->Open Module Settings--->Modules--->Dependencies--->Plus--->Library Dependency, and then you can select one Library Dependency. And then it will be added into your project by Gradle. Most importantly, What You Can See Is What You Can Get. If you can't see the module you want, maybe you need to download it somewhere else.

Android Studio Error - Unable to open PNG file

I am getting the error that is pictured above when I try to build my project in Android Studio.
The file that is mentioned in the error does not exist in that folder. I tried to delete the entire folder hoping it would re-download the needed file. It did re-download the folder but again it did not have that file.
I am not using this file anywhere in my project and as far as I know.
Any help would be greatly appreciated.
Thanks.
Maybe the path of file is too long that it is unable to process it. In my case, it was:
C:\Users\ber$erk-kAjU\Downloads\Compressed\android-xmpp-asmack-sample-master\android-xmpp-asmack-sample-master\XMPPAsmackSample\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.3\res\drawable-ldrtl-xxhdp
As you can see, it is huge! I just moved my project to another path, and reduced it to:
D:\AndroidStudioWorkspace\XMPPAsmackSample\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.3\res\drawable-ldrtl-xxhdp
Maybe this can help!
Use
Build > Clean Project
To clean the build directory.
I think you are using AppCompat library in your build.gradle file
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
In order to use any support library in dependency make sure you have downloaded Android Support Repository from SDK manager
After downloading the repository, do sync the project with gradle using tiny gradle button available in toolbar.
After sync completion you will be able to see mentioned png file in directory as shown :
Inside the directory.
EDIT :
If still doesn't solve check the whether your sdk pointing to right sdk from File > Project Structure > Android SDK
Also check this Import Google Play Services library in Android Studio for AppCompat Library
If there is some issue make it correct ans sync project with gradle.

error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'

I am following the documentation here to install the Android SupportV7 Libary into my project. There are two things that I notice:
1)When I am browsing my SDK installation directory and the Support Library folder, there is no folder named "appcompat"
2)When I install the entire V7 folder anyways I get this error:
error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'
How can I fix this?
(Note: this is in the mediarouter folder)
This is what I see when browsing my SDK installation directory:
http://tinypic.com/view.php?pic=2egehc9&s=5#.UkZqoRbnZAg
If use Eclipse:
You should reinstall your Android Support Library by Android SDK Manager to get the complete android supportV7 library.
The mediarouter library project dependency on the appcompat library project. So,after you have finished Step 1, you can follow Android Support Library v7: Error retrieving parent for item to fix this problem.
Right click the imported android v7 support appcompat library project and open the properties. In android option, choose project build target to be 5.0.1. I hope it works. It worked on my side. It happens because support library contains the functionality of android 5.0.1 and it needs android android 5.0.1 for the build also.
For me none of the solutions worked.Last I copied the android-support jar file to sdk folder and restarted the eclipse.Also i changed the view renderer to level 19 in mainActivity.xml and the errors are gone.
Also check that same jar, android-support-v4 file exists in C:\Users\admin\AppData\Local\Android\android-sdk\extras\android\support\v4 (the location may vary as per your setup).
This way it may support for api level 4 and up.
Note:The jar file is simply the android support library.Please ensure your project libraries contain this jar.
**Easy prosess
If you are using IntelliJ/AndroidStudio
After updating new updates we get these type errors.
so,for old/existing project it will give error.
It won't show for new project,it will automatically take the updated one.
Create new project
New project will not show any errors
and
compare gradle(Module:app) files in both files in both new and existing projects ..
change the existing/old project gradle file according to newproject gradle file
below change worked for me.. according this fix ur
**
compile 'com.android.support:appcompat-v7:25.3.0'
To
compile 'com.android.support:appcompat-v7:25.3.1'

Unable to instantiate activity ComponentInfo, Didn't find class on path: /data/app/ [duplicate]

I have a rather big Android App project that is referencing several library projects. Everything was fine until i upgraded the eclipse ADT plugin to the newest version (v22). I also upgraded the SDK of course. I do not see any compile errors in eclipse, but when i run the project on the phone i get a NoClassDefFoundError.
java.lang.NoClassDefFoundError: org.acra.ACRA
....
The arca library is included in one of the referenced library project (in the libs folder) and i can see it in the "Android Private Libraries" in the package explorer, also as i said, no compile errors. The project runs fine on everyone else's computer that did not upgrade ADT.
I have already tried a whole bunch of stuff including but not limited to:
re-install the android SDK
download a fresh ADT bundle
delete all my code an get it again from git
copy the library in question to the app project
comment out the code that uses this library - i just get the same error for the next library
all without any success, so i'm getting really desperate here.
I would be really happy if anyone could give me a hint on how to solve that problem.
Quoting Streets of Boston from his adt-dev post:
When upgrading, the 'Order and Export' of the new 'Android Private
Libraries' is not always checked. And the android-support-v4.jar is now in
this 'Android Private Libraries' section.
To fix this, go to 'Order and Export' and check 'Android Private
Libraries'. Then refresh/clean/rebuild.
After you done this 'fix' for a library project, you may need to just close
and re-open any depending project, because they may not see this 'fix'
immediately.
Give this a shot and with luck it will solve your problem.
Simply checking Android Private Libraries was not enough, I also had to install Android SDK Build-tools in Android SDK Manager.
I had also the same problem and my adt was 22.0.1. And none of the solution above worked. Further when adding a external library project to a working project.I always check the gen folder of working project and if R of external library project is there (along with package name),then only external library project is exported. And on my gen folder no packagename of external library was shown.
So I checked on project.properties file and there wasn't any external library link present android.library.reference.1= present. So I manually added the external library reference there ,even though I had added from project->properties->Java Build Path->Projects->Add. So manually editing the project.properties did all the work for me.
I have encountered a similar problem, spent about 3 hours, but none of the proposed here decisions did not help... Finally I found a source of the problem: my project files & project.properties were read-only. Eclipse is simply silently ignoring any changes in library dependencies when I doing it in the GUI!
I had the same problem. It was because of the eclipse project.
To solve it I created a new project in eclipse, copy my existing project classes and resources into it and then launched eclipse again and added my custom includes.
I had the similar issue and my answer is slightly different from CommonsWare's. Here is my screenshot:
After checking the libs back in my build started to work again.
I had also the same problem,
i) add gson lib as referecend librairies
ii) check it in java Build Path

Categories

Resources