Android Studio missing src and other part of my project after reopening - android

currently I'm exploring on using the Android Studio. It's been a while since I last developed on Android and this is really exciting for me having a new tool to develop in Android. Now I already setup the Android Studio successfully and already tested to create a new sample project last week but today after I opened it a message appears saying that "the folders below are removed from gradle..." it has a checkbox and I don't know why it's checked by default. Since I'm not yet that familiar with the environment I pressed ok then all the src and other folders are now missing. Although I can still access the src folder as well as the classes I created through the use of the navigator on the top part but I can't run the app and it acts really strange compared from before.
Also when I try to create a new project a message appers saying:
"Failed to import new Gradle project: Could not fetch model of type 'IdeaProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Unable to start the daemon process."
Not sure on what to do about this one. Well I know this is still in beta and bugs happen but I hope there's already a workaround for this.
Anyway, here's a screenshot on what happens to my project:

So I tried searching answers based on the error message I got from creating a new project and found out about this one:
Failed to import new Gradle project: Could not fetch model of type 'IdeaProject'
works like charm indeed.

Related

Android Studio creates no Main Class and layout file

I try to create a new Android Studio Project.
Till today creating new projects was done by a simple dialoge window in which you had to determine the project name and the minimal API Level. After doing that the project structure opened and a MainClass and a layout file had already been created.
Now there is a window where you have to determine whether it should be created by Gradle or be just a simple Java Project.
OK it may be an update... Now the strange part starts...
I now get asked to enter an artifactId and a GroupId. (Is this an equivalent to the project name?)
After another new but less confusing window the project was created but the Project structure has changed:There was no module "app", there was altough a Java directory existed no (usually autocreated) Main class or layout file.
(Project structure and the non existing Mainclass can be seen in the picture)
When trying to open an existing project the IDE throws two errors saying that there was no File named "name of the project".iml and app.iml.
I have already tried to reinstall Android Studio.
Is this an update?
Did I mess up settings?
Solved it by deleting not just android studio in system settings but also in registry.
After reinstallling it finally worked.
Thanks for your help
There is a window where you have to determine whether it should be created by Gradle or be just a simple Java Project... I now get asked to enter an artifactId and a GroupId.
Sounds like you made a Gradle project, not an Android app.
The new useless project structure
Maybe useless for an Android project, not a plain Java codebase.
Did I mess up settings?
Possibly. The Android IntelliJ plugin may not be loaded properly

Visual Studio 2017 - Xamarin - The file "obj\Debug\android\bin\packaged_resources" does not exist

I'm fighting with that issue for 2 days already and can't find any solution.
I have an Xamarin Android app in Visual Studio 2017 consisting of three projects:
Xamarin.Android project (main one)
Android-specific unit tests run on the device - project of type NUnit 3 Test Project (Android) created using NUnit Templates for Visual Studio
Platform-independent unit tests project (project of type Unit Test Project (.NET Framework))
Everything worked just fine until now. When I selected my main project as the Startup one, my app was deployed to the device/emulator. When I selected my Android-specific unit tests project, the test project was deployed and unit tests executed by nUnit Xamarin Runners on the device/emulator.
However few days ago I updated my Visual Studio 2017 with the newest available update and now, when trying to build this android-specific unit tests project I get the following error:
The file "obj\Debug\android\bin\packaged_resources" does not exist.
I've searched everywhere, including this and this SO topics. I also totally reinstalled Visual Studio 2017 and Xamarin with Android SDK included. Nothing helped. From what I read I suspect there is something wrong with the versions of Android SDK Build-tools I have installed. Here's what I have currently installed in SDK Manager:
As the other SO threads suggested, I tried uninstalling the newest Android SDK Build-tools (25.0.2) and installed version 23.0.3 (all my projects target Android 6.0), but it also doesn't help, I still have the same error.
Maybe it's worth adding that this issue may have started to happen when I tried to implement RecyclerView in my app reading this tutorial, where they suggested to install Android 7.1.1 (API 25) in SDK Manager. However I undoed my all changes after that and even reintalled VS2017 + Xamarin.
Do you have any other idea why this can be ? I'd really appreciate any help. Thanks!
EDIT 2017-04-09:
Egh, I removed VS2017, installed VS2015 with brand new Android SDK and still the same issue :(
I've finally found what was the issue. It wasn't related to any component from SDK Manager or VS version.
Following localization tutorial from developer.xamarin.com, I played a bit with Strings.xml in my Android project. I wanted to have my Activities Label taken from resources as well, so in the ActivityAttribute I defined:
[Activity(Label = "#string/peopleListTitle")]
and added this value in Strings.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-------Other resources values ----->
<string name="peopleListTitle">People List</string>
</resources>
In that case my build is failing with above-mentioned error:
The file "obj\Debug\android\bin\packaged_resources" does not exist
When I change ActivityAttribute to use a string directly:
[Activity(Label = "People List")]
the build is passing without any issues.
I managed to find a solution, but actually I don't know why it's not building when I try to use Label text defined in Strings.xml.
BTW, I managed to find what's the problem by setting build output verbosity to Diagnostic in Tools -> Options -> Projects and Solutions -> Build and Run which gives a detailed info why the build failed in the Output window.
I had the same problem. After removing the dash "-" sign from the image file name, the problem is solved. Bad error message! It should not be:
The file "obj\Debug\android\bin\packaged_resources" does not exist.
Writing an error message like this causing the Developer to think about something else while the problem is the illegal file name.
I had the same issue when I added a new image as a resource.
There was a '-' in the file name (Invalid resource name character). I renamed & removed that character and all good.
Resource name can only consist of 0-9,a-z or A-Z or combination of any.
I had the same problem, and i removed all image file name have "-" character. My problem solved
Another reason for this error is that you may have a float number as your version number. In my case I changed it to a integer and everything worked fine. (I found the error by switching the build output to Detailed)
Simply it worked.
In one case I copied and pasted previous working "packaged_resources"
in the bin folder.[the problem was it did not reflect the UI changes]
Other I opened the visual studio as
administrator.
Next changed the "Minimum target to Android" to lower
apis in the project properties windows.
I suggest not touching the code behind of the design. If you get this error simply pull some button from the tool bar into the design and visual studio will come to its consciousness that there is change in UI. Next click on save all so that it make necessary change in the designer file.
Mine was a different solution (and only half a day lost): I was having trouble getting Hockey app to match crashes against the correct version of the app and realised it uses VersionCode not VersionName so I change my code to "0.0.34" the same as the name. For some still unknown reason the app built and deployed to devices for about 3 days before I started getting this error The file "obj\Debug\android\bin\packaged_resources" does not exist. Setting it back to a numeric value fixed the problem.
I found the problem by looking back through my GIT logs and rebuild each push until I found the one that caused the problem.
It just because the Version Code,I set Code by '1.0',The file "obj\Debug\android\bin\packaged_resources" does not exist.;And I set it by '1',everything is ok.
Had the same error, the way I got over it was crank up the Android SDK manager and install all updates and remove any obsolete packages. This happened to me because I was targeting something newer which was not installed.
Check to see if there are any unused entries in resources.designer.cs if there are any manually remove those entries.
This will fix the issue.
After following several online suggestions - updating SDK, updating Xamarin etc - none of which worked for me.
Finally found that I had an activity for a Android provider to Alarm clock in my AndroidManifest file as below
<activity
android:name="com.njcommuter.droid/android.provider.AlarmClock"
android:label="AlarmClock"
.....
/>
Removing this line - and rebuilding worked fine without any errors and was able to deploy solution successfully.
Note : testing this by putting the line back, and I get same error again on rebuilding.
It can be linked to using any android provider which creates the package for it, not necessarily AlarmClock only.
This error is, somewhat of, a wrapper for what can be multiple reasons that that the file was not created. The key is to look in the detailed output and look for the underlying error causing the file creation failure.
In my case, I had corrupted icon.png files (generated right from from the VS xamarin nunit template, no less!). Once I put in valid png files, everything was built fine.
Another reason for this error, if that the android NDK (not android SDK) isn't right, change de version can resolve the problem: go to Tools/Options/Xamarin/android Configurator and change de folder, in my case I've three, the last one can't compile, but the second folder with version xx.r11c do it.
For me it was Target Android Version.I had it set to
but changing it to Compiling version(for me it was the latest platform) resolved the issue.

Unable to import the existing Eclipse project structure to Android Studio

I have a problem with the import of my company's project into Android Studio.
First of all, we have a project which contains desktop clients (Java) and mobile clients (Android). The project structure under Eclipse runs fine.
But since Eclipse and ADT is not longer supported by Google, I thought it is time to switch to Android Studio (I am the first one, who is trying this).
Our project (trunk) has a structure like this:
10 Folders which doesn't contain relevant code for the Android Client
mobile (Android based code)
projects (Android xmls, manifest and all other non-Java stuff)
sharedContent (pure Java)
"mobile" contains all the specific source code for the Android client.
The "projects" folder contains a folder "android", which contains all necessary xml-files and the manifest.
The "sharedContent"-folder contains a "sharedME" folder. The code from the "mobiles"-folder uses some code from the "sharedME"-folder.
This three directories are required for the Android client.
The main problem is, that I am not allowed to change the project structure to one, which is more suitable for Android Studio. The reason is, that at first the package declarations wouldn't be correct anymore, and secondly other important code from the project will have problems with the changed structure.
Since we used to import the trunk with SVN, everything worked fine under Eclipse. But I can't integrate the code successfully in Android Studio. I tried many different ways (and tutorials), but none of them worked for me. Note, that the import into the workspace seems to be no problem. But when I am trying to build the project, Android Studio shows me several errors.
I won't show you, what errors I am receiving, because they would be from many different approaches.
I want to start from scratch by asking you, how you would import this project structure with given setting into Android Studio. Maybe I tried the right way, but just made something wrong.
The most favourable solution would be, when the project is connected to the SVN, so that we are able to commit or checkout changes from the SVN directly from Android Studio. But since this doesn't seem to work either, it is ok to commit them manually from the workspace.
I am glad for any suggestions. Just post your ideas, and I will responed with the error output I get or if the solution was successful.
EDIT:
I imported the three most important directories with SVN into Android Studio. Now I have three modules: "android", "mobile", and "sharedContent"
The only error I get is "cannot find symbol, symbol: class R". R is located in android->gen->com->...->project->R. The error is created by the files from the module "mobile", to be exact from mobile->android->com->...->project->A random Class.
Is there a way to point to the R-class, which is located in another module?
Android Studio shows the error at first in the import, like "import com. ... .project.R". I set them as sources, but it didn't work, yet.

Not able to find Application Class in new setup for couple of project in JellyBeans and new eclipse

I already had eclipse with android plugin and ICS. Sometimes i faced problem after updating to new version of ADT plugin. So to work with jellybeans (4.1), i downloaded and installed new android on different folder in programmeFile foder, and new eclipse(Juno Classic Version: 4.2.0) in different folder. after configuring both i used same workspace for new eclipse which i was using for older eclipse. Now my two project which have external jar is not working in this eclipse. even though i crated new project from cvs yet also it is not working. and after crating project in new eclipse even though if i come in the old eclipse i am not able to run it. It is showing following exception. The problem is it is not able to find my application class and it says could not initiate Application class because it could not find it but it already defined in manifest file. Other small example project do not have there own application class that may be one reason they are working fine. The exception is as follow. Any suggestion or help is welcome.
java.lang.RuntimeException: Unable to instantiate application com.muvee.vea.MveaApplication: ****java.lang.ClassNotFoundException**: com.kartik.MveaApplication**
07-12 09:43:01.100: E/AndroidRuntime(6012): Caused by: **java.lang.ClassNotFoundException: com.kartik.vea.MveaApplication**
07-12 09:43:01.100: E/AndroidRuntime(6012): at android.app.LoadedApk.mak
Start your old eclipse with a new workspace, checkout your project into your new workspace and try to run it. Does it work?
Start your new eclipse with a new workspace, checkout your project into your new workspace and try to run it. Does it work?
Also did you say you installed the Android SDK twice? No need for that though.
The answer lies on the following link. we need to specify external jar in Order and Import tab. You can refer this link for more details.

Eclipse not automatically switching run configurations

Everything was working fine yesterday. I start to work on my project today and Eclipse gives me a bunch of problems. First, it wouldn't let me debug saying "Cannot connect to vm". I don't exactly remember how I fixed that problem, but I did. I was able to debug once again. I just recently created a new project to test something separate from my main project and now Eclipse is giving me some more problems. This time it is saying "An internal error occurred during: "Launching New_configuration".
Path for project must have only one segment."
After some searching, I found that it is related to the debug configurations. In order to debug a project now I have to go to Run->Run Configurations and select the project I want to debug. Before, it would automatically do this for me. I would just select a java file from a project and it would debug the project that contained the file. Also, I can't find my new project in the list of Android Applications under Run->Run Configurations. I've tried creating a new one in the menu, but when specifying a source it can't find my project folder even though it is clearly open in Eclipse. Eclipse has been giving me massive headaches lately and I don't understand what could have caused this to happen. Eclipse was left open all night and the computer doesn't go into sleep mode (sorry for wasting power!).
Any ideas on how to get it to see my project and make it automatically debug the right project?
What is the usual case (detailed below as a Run or Debug configuration with no project name) wasn't the root cause:
In the comments, I suggested:
Did you try to import this existing project in a brand new workspace? (to see if this isn't related to some kind of workspace metadata corruption?)
To which the OP Atlos replied:
creating a new workspace seemed to have fixed it. Not sure what could have happened to my old workspace to cause a problem like this.
Should I ditch my old workspace and just import stuff into the new one?
It happens, and can be caused by some process blocking the update of metadata, rendering parts of the workspace unsound.
It is perfectly OK in that case to save/move that old workspace (for reference just in case) and to create a brand new one.
This blog post mentions:
It seems that this rather cryptic message means nothing more in my case than “please enter a name and project for your run configuration”.
I did have a “name”, but left the “Project” field empty. Entering a value in the ‘project’ (the “AndroBlip” you see next to ‘browse’) fixed it.
Sources seem to indicate that the same error is produced if you don’t enter a value in the ‘name’-field.
It actually references the similar SO question "Android: “Path for project must have only one segment”".
Note that you would see the same error for trying to have a project within another project (as detailed in this thread).

Categories

Resources