Eclipse shows error (unable to resolve target) - java

I got a project and imported it in Eclipse (it is an android project).
The project works on other computers, but unfortunately not on mine.
The error which comes up is in the console of eclipse when i import the project:
"Unable to resolve target 'android-8'"
Furthermore do i get multiple errors in on of the .java-files in the src folder of the project.
3 of them are showing "String cannot be resolved to type":
Here the code (It is for a music player the timer /showing of the seconds):
/**
* Function to convert milliseconds time to
* Timer Format
* Hours:Minutes:Seconds
* */
public String milliSecondsToTimer(long milliseconds){
String finalTimerString = "";
String secondsString = "";
I hope you can help me!
Thank you so much in advance!
If you have any questions please let me know.
Thanks guys.
Cheers

You'll be having project.properties file open that and change the android-8 to whatever android version you have. After changing this goto Window->Preferences->Android. You'll be having target name & api level. select any one of them & specify it in project.properties file.

It seems you have something set with a build target of API 8. Perhaps a subproject or library?
If that's intended then it sounds like you need to download Android 2.2 (API 8) through your Android SDK manager.

Right click on the project, Properties -> Android -> Select the build target -> Apply -> OK

Related

aws "Cannot create enum from " + regionName + " value!"

I am working on aws. I am getting "Cannot create enum from " + regionName + " value!". I know we could change to the latest SDK jar file, but I want with out changing the jar file to rectify this issue. I am facing this issue at Regions.fromName(String regionName) method. Here is my code:
for(com.amazonaws.services.ec2.model.Region region : describeRegionsResult.getRegions()){
String regionName = region.getRegionName();
Regions regionsValue = fromNames(regionName);
Region regionToDiscover = Region.getRegion(regionsValue);
}
Is there is way to convert describeRegionsResult.getRegions() to com.amazonaws.regions.Regions.
The latest version of the Java SDK as of this answer (1.11.13) supports the following Regions:
Enum Name
Regions.GovCloud us-gov-west-1
Regions.US_EAST_1 us-east-1
Regions.US_WEST_1 us-west-1
Regions.US_WEST_2 us-west-2
Regions.EU_WEST_1 eu-west-1
Regions.EU_CENTRAL_1 eu-central-1
Regions.AP_SOUTH_1 ap-south-1
Regions.AP_SOUTHEAST_1 ap-southeast-1
Regions.AP_SOUTHEAST_2 ap-southeast-2
Regions.AP_NORTHEAST_1 ap-northeast-1
Regions.AP_NORTHEAST_2 ap-northeast-2
Regions.SA_EAST_1 sa-east-1
Regions.CN_NORTH_1 cn-north-1
You can see when each region was added into the SDK here: https://github.com/aws/aws-sdk-java/blame/master/aws-java-sdk-core/src/main/java/com/amazonaws/regions/Regions.java
If you are trying to use one of those names with Regions.fromName, but your version of the SDK doesn't have that yet, it is impossible to get an enum for that region. You must upgrade the SDK or keep the region as a String.
dont know if its still relevent but my problem was that i wrote the region as:
US_EAST_1
but the right way to write it is:
us-east-1
I replaced Region.US_EAST_1 with us-east-1 and it worked.
I think we can skip the enumeration and directly add the region awsconfiguration.json file
For android add latest dependencies... solved for me...
compile 'com.amazonaws:aws-android-sdk-core:2.3.3'
compile 'com.amazonaws:aws-android-sdk-sns:2.3.3'
You can try updating Maven Project with Force Update Of Snapshots/Releases as checked.
Steps to do so:
Right Click on your java project from Project Explorer window.
Go To Maven. Go To Update Project. (For Eclipse users you can directly go to update project by pressing key combination of Alt + F5).
A window with the title Update aven Project will appear, make sure that your project over there is listed and checked.
Click on "Force Update of Snapshots/Releases" checkbox.
Click Ok Button.
Try To Re-Run your code and see.!

Android Studio 2.1 Cannot resolve symbol 'R'

Android Studio 2.1,
Java V8 Update 91, Gradle 2.1.0 .
I know that this questions has been asked many times here, but none of the recommendation solutions works out.
In a sudden after compiling ready to run on Emulator, my IDE give an error at the R.id attribute. Every Java files suddenly give the same error even I don't make any changes to the file.
I tried to make a new project, see if things different but the error keep coming. In my mind it could be internal error, again. Even I just update my IDE just now.
The Java file;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_science);
list_View = (ListView) findViewById(R.id.maintable);
String[] Days = new String[] { "Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday"};
dayList.addAll(Arrays.asList(Days));
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, dayList);
list_View.setAdapter(adapter);
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
if (nfc.isEnabled()) {
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, dayList);
Toast.makeText(this, "NFC turned ON", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(this, "Please turn On NFC", Toast.LENGTH_SHORT).show();
}
}
The R is the error.
XML file that associate to the Java;
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/maintable"
>
</ListView>
Is this, again, an internal error?
Try syncing the project, go to Tools > Android > Sync Project with Gradle Files
UPDATE
If you're using Android Studio 3.3, use the Sync Project with Gradle Files icon
I have just gone through this nightmare. Ended up removing all xml code to notepad until it was fixed. Then reintroduced sections of code until problem appeared.
Thinking back, it all started when I pasted some code using WordPad. Apparently WordPad contains a different coding or something so bet to avoid.
Anyway just check your white space in xml by deleting it all to rid yourself of any hidden characters.
Try performing a clean and rebuild by going to Build > Clean Project and Build > Make Project
Sometimes the R.java class is not created when there is some error into an xml file (like activity_main.xml). For example, if you change some attribute name that has a reserved word that cannot be changed.
Like this: if you changed the attribute called: id to another name like
id_A_Word_With_Error_Here in this code that can be part of the activity_main.xml, your error (R class not created) can occur.
<android.support.v7.widget.RecyclerView
android:id="#+id/messageRecyclerView"
and there is an error like:
<android.support.v7.widget.RecyclerView
android:id_A_Word_With_Error_Here="#+id/messageRecyclerView"
If clean, rebuild did not work and there is no error with import like import com.something... , my suggestion is to search an error into xml files.
I've seen this problem many times. The right solution is:
When you type R, the Android Studio will give you many different namespaces for R to choose from, that look like R(***.***.***), but what you really need is the namespace that ends with ***.myProject. (Note: myProject is your project name), e.g: R(com.example.milka.demoProject).
If you choose any other namespace, you will get the error message, so you have to delete the unneeded import, and re-choose your R
I try to change the Gradle version from 2.1.0 to 2.0.0, even in AS ver 2.1, ignoring the Instant Run performance and its work out. The little R error is now gone. Now, I tried to change back to 2.1.0, the R error also gone..!!
Sometime this little thing drive me crazy, a bit.
Shame on me.
Maybe the error may cause for the tools, trying install Android SDK Build Tools from Tools > Android > SDK Manager.
or maybe this error can be caused by adding an activity to a namespace that is different to the root, you can trying >>Import com.example.MyApplication.R;
or your also can clean o rebuild your project in Build > Clean Project or Build > Rebuild Project
If you are using google play services and your compilesdk version is lower than 23 then download the new sdk and update your compile version. After that try cleaning and rebuilding. It will be fixed
Have you tried Rebuild Project go to
Build> Rebuild Project
and perform it without doing the Clean project
I had the same problem & it worked for me

Exception in thread "main" java.net.UnknownHostException: services.gradle.org

I am getting the below error when executing gradle.bat. I have checked the URL path and it looks fine. The URL is defined like this in the wrapper properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip
Here's the error message:
Downloading https://services.gradle.org/distributions/gradle-2.1-bin.zip
Exception in thread "main" java.net.UnknownHostException: services.gradle.org at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
Could someone help me on this?
Go to "C:\Users\[yourusername]\.gradle\" folder (hidden folder - Go to folder option and enable show hidden files if folder is not showing up)
Look for file "gradle.properties" if DOES NOT (most likely this would be the case) exists, Create it under "C:\Users\[yourusername]\.gradle\
Copy and paste following code (More detail ... https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties ... look for "20.3 Accessing the web via proxy" for https and user/pwd variables)
systemProp.http.proxyHost=[PROXY SERVER]
systemProp.http.proxyPort=[PROXY PORT]
save and try again
look for gradle.properties file open it and change from 'distributionUrl=https\' to 'distributionUrl=http\' that will fix it.
I was facing the same problem when I was connected to WiFi with a download speed of 80 Mbps which is good enough, I guess. After spending hours while still being clueless, I just changed the network. Connected to hotspot from my mobile data with a much lower download speed of around 4 Mbps. The error vanished! Maybe something was wrong with the WiFi.
1) Go to your project directory
2) Find below file on your project directory:
gradlew
gradlew.bat
3) Edit gradlew file and change DEFAULT_JVM_OPTS variable value as below:
DEFAULT_JVM_OPTS="-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX"
save it.
4) Edit gradlew.bat file and change DEFAULT_JVM_OPTS variable value as below:
set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX
save it.
5) Now run your "gradlew clean build" and check.
Please set your appropriate value on the place of XXXX
Note: gradlew is use for linux system user and gradlew.bat is user for window system user
Make sure you have enough bandwidth for the download.
I had the same problem just 15 minutes ago (that's why I'm on this page in the first place). Same error message --- and then I noticed that my uTorrent client was occupying the whole datalink. So I killed it, and run gradlew.bat again. This time everything went just fine...
I had similar issue, fixed by following steps:
Created: C:\Users\<username>\.gradle\gradle.properties
Values entered in the property file as below:
systemProp.https.proxyHost="company proxy server"
systemProp.https.proxyPort="company proxy port "
systemProp.https.proxyUser="user login "
systemProp.https.proxyPassword="password "
systemProp.https.nonProxyHosts=localhost
You can try HTTP instead of HTTPS.
I had this problem for a flutter project and what I did was create a new flutter project with the same name as my problem flutter project. I then copied the files from the "android" directory from the new project into the existing flutter project. Basically some set up file was messed up. I don't know which one, but this did the trick
Maybe it's a bit late but you might have to try to UPDATE your ANDROID STUDIO. Had a similar problem, working on Linux pop_os (Ubuntu derivative). So I had Android SDK on my $PATH and everything set well but Ionic v3 build was having a Gradle issues while trying to download.
I simply updated my Android Studio and tried again and it worked. Good luck
Go to your command prompt and set the HTTP and HTTPS proxy
Execute the below in your cmd -
set HTTP_PROXY=http://<proxyservername>:<port>
set HTTPS_PROXY=http://<proxyservername>:<port>?
Once you have set your proxy variables , try rebuilding or re-assembling your application / project
I've got an issue with Android studio. The value of the distributionUrl field in the graddle-wrapper.properties has been changed during package name refactoring.
If error is under flutter
Just hoping this might help someone in the future...
When i encountered that error in flutter, I just had to change network from the current one which seemed unstable, am sure build.gradle was trying to get more resources from internet.
try disconnecting and reconnecting to the network
try changing networks(wifi- date or data - wifi)
In my case disconnecting from my office VPN fixed the problem
Just remove your .android and .gradle folder from C:\Users\[Your user name]\
Uninstall android studio and reinstall it
Open any simple android studio project and run it. It will automatically set up the Gradle and other things
Close the project and run your flutter project. It works for me!!!

"File not found" when running new LibGDX project

I trying to learn LibGDX, I install all the software listed here with a new Eclipse 4.3 on a fresh formatted mac OS X Maverick.
Everything goes smooth, after a reboot, I download, and execute the gdx-setup.jar, fill the form, and import into Eclipse.
No error, no warning, when I try to run the desktop. (Right click the desktop project, Run As -> Java Application).
I got this error
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
at com.diesel.bugs.DieselBugs.create(DieselBugs.java:21)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: badlogic.jpg (Local)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:134)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:218)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
I found a lot of similar issue here, I try them all without any good result... Last night I found this, very cool I have the latest Java 1.8, a mac, and Eclipse fit perfectly...
But no success, I try with Java 1.6 and 1.7, Always the same error (No file found, I kept Java 1.7)
I begin to do some debug, here my only modification of the original code generated by the importation.
package com.diesel.bugs;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class DieselBugs extends ApplicationAdapter {
SpriteBatch batch;
Texture imgExternal,imgLocal;
#Override
public void create () {
batch = new SpriteBatch();
String pathLocal = Gdx.files.getLocalStoragePath();
String pathExternal = Gdx.files.getExternalStoragePath();
Boolean isExternal = Gdx.files.isExternalStorageAvailable();
Boolean isLocal = Gdx.files.isLocalStorageAvailable();
imgExternal = new Texture(Gdx.files.external("/Desktop/badlogic.jpg"));
imgLocal = new Texture(Gdx.files.local("badlogic.jpg"));
}
#Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(imgExternal, 0, 0);
batch.end();
}
}
The weird thing is pathLocal is equal to "". Is it normal for Gdx.files.getLocalStoragePath() to return nothing (empty string)?
Also the
imgExternal = new Texture(Gdx.files.external("/Desktop/badlogic.jpg"));
Works great. only the local one gives the error, also isLocal, and isExternal return true.
And I try a lots of combinations, like /assets/data/badlogic.jpg, /assets/badlogic.jpg, /data/badlogic.jpg, data/badlogic.jpg, and badlogic.jpg.
The image badlogic.jpg is there and I put it in multiple places to be sure.
And now the reason why I'm here for help is I just try all the same step on a PC and everything works great.
What is wrong with my new mac and it's setting?
From libgdx wiki
When you run Desktop Project
The application will fail the first time. Open the Run Configuration you just created and set the working directory to the android/assets/ directory!
link your desktop project to android assets folder?
Go to Run => Run Configurations.. => choose DesktopLauncher, Arguments Tab => Working Directory => Others then browse to yourproject-android/assets/ and click Apply => Run
For those of us using Android Studio or IntelliJ IDEA, you need to follow these steps:
Select Run -> Edit Configurations from the menu
In the "Working Directory:" text box, append "/android/assets" to the path.
Note that if you execute tasks with gradle, this is not an issue. The gradle.build files are configured to use the assets folder from the android module.
Note that the previous answers will not work for users who unchecked the "Android" box on setup. There should really be a default assets folder installed for those who don't care about deploying for Android.
For those using Intellij IDEA:
Run -> Edit Configurations
On the left hand side choose: Application -> DesktopLauncher
In the "Configuration"-Tab, undert "Working directory" choose your android/assets path
This is how you fix it properly without playing around with the working directory:
The problem is that the asset folder is not correctly marked as resources directory for the gradle build. To fix this you have to add the following line in the ./core/build.gradle build file:
sourceSets.main.resources.srcDirs = [ "assets/" ]
My file after a clean setup with the recent libGDX version looks like this:
apply plugin: "java"
sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.resources.srcDirs = [ "assets/" ]
eclipse.project {
name = appName + "-core"
}
I use a different solution.
Instead of creating an application run configuration, create a Gradle build configuration. The task is desktop:run. Once it is executed, the game (should) launch and stay alive without crashing, and the resources should be found.
I am not exactly sure why, but when a Gradle task is run like this, the resources are found. When an application run configuration is used (without modifications like the currently accepted answer) it crashes because it can't find the resources.
I had the same problem in IntelliJ, and I had not generated the libgdx project for Android (Android option was not marked as checked) and I was yet getting the same error. Instead of linking the working directory to "/android/assets/", linked it to "/core/assets" and it worked fine for me.
I haven't Android project. My solution is to add the asset folder to the Java Build Path->Libraries as a Class Folder. Additionally check the asset folder in Java Build Path->Order and Export to include this in other projects.
You can check the path of Assets in working Directory or linked resources .After done check for the file which you are loading .At last clean and refresh the project and enjoy.

Eclipse Error: 'AndroidDataBase' is missing required Java project: 'GoogleMaps'

I am developing an app named "AndroidDataBase".
while am trying to compile in eclipse I am getting this error
Error executing aapt: Return code -1073741819 AndroidDataBase line 1 Android ADT Problem
and
Project 'AndroidDataBase' is missing required Java project: 'GoogleMaps' .
Where GoogleMaps is another androidApp.
I have the GoogleMap.java in AndroidDataBase "Src" folder.
I have tried clean build ,restarting eclipse sort of things ,still no result
Why am i getting this error ,and how to resolve it?
Thanks in advance
I have added the GoogleMap.java
the issue is activity_googlemap its not getting identified
although it is present in res/layout
You need to add the "google-play-services_lib" project as a library project. You will find it in your_sdk_root_path/extras/google/google_play_services/libproject/google-play-services_lib
Set your Project Build Target to Google API Build. From right click on project and go to Preference>Android tab>Select Target build of Google API.
I Dint installed the "Google Play Service" present in the SDK Manager .
Once I did that ,all I need is to follow the solution of # Joan P.S(Stated above I have accepted the ans,thanks to him.).
After that I have to add the Google MAP project(import it to the current work space(another app )) in Properties->Java Build Path->Projects .
That's how it got solved

Categories

Resources