I had to change my package name from com.example.chris.myapplication to com.tamaritz.chris.myapplication so that my app could be properly loaded and distributed via Google Play Store. To do this, I used the approach Android Studio Rename Package which was to basically create a new directory, copy contents, update Manifest. I got those steps down but I am having trouble with "change/rename the R file imports in whole project". When I made my package name change, my line of code(below) said "R cannot be resolved".
submit = (Button) v.findViewById(com.example.chris.myapplication.R.id.submitButton);
When I went to the imports part of the java source code(below)
package com.tamaritz.chris.myapplication;
import android.app.Activity;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
Everything seemed to be line place, the right package name.
Do I have to put a manual R import? The person said to change/rename the import but I don't even see the original R import.
And this something else I did which I am not sure. A possible solution I found was just to do alt enter, and import the class. That line of code suddenly turned into
submit = (Button) v.findViewById(R.id.submitButton);
Is this a valid approach. Does the package name explictly need to be there? After I did this, i did not see any changes in the import section either.
Related
I want to import the packages, for example:
import java.io.PrintWriter;
import java.text.DateFormat;
import java.util.Date;
these packages have already existed so it doesn't pop up any error messages.
When I want to import others packages:
import com.businessobjects.rebean.wi.DocumentInstance;
import com.businessobjects.rebean.wi.Prompt;
import com.businessobjects.rebean.wi.Prompts;
import com.businessobjects.rebean.wi.ReportEngine;
import com.businessobjects.rebean.wi.ReportEngines;
import com.crystaldecisions.enterprise.ocaframework.ServiceNames;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.plugin.desktop.folder.IFolder;
It will say "the import cannot be resolved", but where I can get the jar files to resolve these problems?
I tried to search these jar files in the java lib folder but was not able to get them.
Can anyone tell the exact folder path for these jar files, if it is there?
Or where can I download those packages.....
I found the website (https://help.sap.com/doc/javadocs_bip_42/4.2/en-US/bip/en/com/crystaldecisions/sdk/exception/package-summary.html) but I still don't know how to import it......
You'll need rebean.wi.adapter.jar and cecore.jar. They are located in the following directory with BO client or server software is installed:
C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\java\lib
Note that these are not available publicly -- you will need to install the software.
I have a multitude of problems stemming from one central issue: Android Studio isn't recognizing imports.
For example, in my class "ActivityAbout" I have the following import statements:
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.AnimationUtils;
import android.widget.ViewFlipper;
However, in the IDE (using the first import statement as an example), the import android.content. is appearing grayed out, and when I hover over it, it says "unused import statement" the Intent part is appearing red, and when hovering over that, it says "cannot resolve symbol Intent." This occurs for each of my import statements, with the first part being grayed out, and the last part being in red.
Now, this provides a multitude of issues in my code, as anything relating to those import statements appears red and when hovering over it, I get the message "cannot resolve symbol ____"
Here's the kicker- my app still compiles and runs upon opening it on my phone.
I suppose my main issue is that it is incredibly annoying, and auto imports doesn't work either. (I have checked off 'show import popup' in the settings, which is the answer I found for other people having issues with auto import not working). My other concern is that this would make my app ineligible for release on the play store. I'm still looking into the publishing process, so I don't know if that is actually an issue or not.
My question (if no one has an answer for how to fix this) is: is this a problem with the IDE itself or the code?
EDIT: added the other import statements
I just had this issue.
I resolved it by clicking File > Invalidate Caches / Restart... > Invalidate and Restart.
When Android Studio restarted and indexed all my code again, the issue was gone.
I have no idea what caused it...
I had a similar issue with my project. I resolved it by going to File > Sync with File System and then closing the project and importing it again
You may need to resync with the gradle again but hopefully it works for you
This question already has answers here:
R cannot be resolved - Android error
(108 answers)
Closed 6 years ago.
In my MainActivity.java file, I have no errors expect for one that shouldn't be there:
Cannot resolve symbol R
My imports are:
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.text.InputType;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
Is there an import I am missing that enables R to work properly?
You can solve this problem by first "cleaning project" and then by opening "Tools" then "Android" and then "sync project with grade files"
If that doesn't work try importing the R class in the mainActivity class itself i.e.
Example:
import com.example.androidproject.R;
Here you put your own project domain name and project name i.e. replace com.example with your domain name and androidproject with the project name...p.s. any problem comment below...
Here's the thing: I've downloaded the javax.mail API, added it under Libraries->Add Jar/Folder. I've compiled the code, but it keeps yielding an error on the 'import javax.mail;' sentence, saying that the package does not exist. What is going wrong?
You've mentioned this line:
import javax.mail;
This won't work, because mail is a package and not a class. Either use:
import javax.mail.*;
to import the whole package or import specific classes using:
import javax.mail.Header;
import javax.mail.Message;
import javax.mail.Session;
(the classes are randomly selected and should only show how to import a specific class)
you commented
I've extracted the javax.mail JAR file to the netbeans8.0.2 folder
you dont need to do that,
it should be enough to put the jar in your project's lib folder and maybe reference it in the build path.
cheers
So i made it finally to the final stage of my simple java app that runs under windows and is used to get the user name and log it in an remote excel file. up until now everything is ok.
When i Externelize (does that word exist?) the app to make it a runnable jar the size of the app was 22Mo! wich is huge since i want to use it in an email (outlook).
Here come the question (finally). Can i delete any of the default java jars in the classpath and the app will still run ?? if yes, which ones??
NB: i tried including the imports in the SS if it does help
NB2: the Jar of the app it self is just 20Ko , the ressources are around 22Mo .
By the way thank you all for helping me make this app it was thanks to this website eventhought i didn't ask any question up until now you'll still answered them all..You rock !
Those are my imports:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.wb.swt.SWTResourceManager;
EDIT: So after the discussions i managed to reduce the size of the app to 8Mo by deleting some of the jar in the referenced library (org.ibm.icu.jar). The app still runs perfectly without it
A jar file is just a zip file, so what I would do is simply unzip the file and see what comes with it and what is large. The standard java libraries, should not even be part of your JAR as they are part of the JRE.
However, my suspicion is that you use Apache POI and that is huge. So if you are writing to an Excel file you might have to stick with that size or find another library.
You could for example write the output as CSV which is very lightweight.