Ad
Android Studio - Cannot Resolve Symbol R
I've added an XML file app_tracker.xml
under the res\xml
directory, but it seems that Android Studio cannot find it.
I've rebuilt and synced Gradle multiple times, but it did not work. How can I resolve that?
import android.app.Application;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
import android.R;
import android.R.xml;
import java.util.HashMap;
/**
* Created by David on 12-Mar-16.
*/
public class MyApplication extends Application
{
// The following line should be changed to include the correct property id.
private static final String PROPERTY_ID = "UA-75038910-1";
//Logging TAG
private static final String TAG = "WiggleTasks";
public static int GENERAL_TRACKER = 0;
public enum TrackerName {
APP_TRACKER, // Tracker used only in this app.
GLOBAL_TRACKER, // Tracker used by all the apps from a company. eg: roll-up tracking.
ECOMMERCE_TRACKER, // Tracker used by all ecommerce transactions from a company.
}
HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
public MyApplication() {
super();
}
synchronized Tracker getTracker(TrackerName trackerId)
{
if (!mTrackers.containsKey(trackerId))
{
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker t = null;
if(trackerId == TrackerName.APP_TRACKER)
{
t = analytics.newTracker(R.xml.app_tracker);
}
else if(trackerId == TrackerName.GLOBAL_TRACKER)
{
t = analytics.newTracker(PROPERTY_ID);
}
mTrackers.put(trackerId, t);
}
return mTrackers.get(trackerId);
}
}
Another issue came up. I'm suddenly getting the following error:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: org/objectweb/asm/AnnotationVisitor.class
What can be the reason?
Gradle File
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
compile 'com.parse:parse-android:1.+'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services-appindexing:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.gms:google-services:2.0.0-alpha6'
}
Ad
Answer
Make sure you have the file main\res\xml\app_tracker.xml
setup correctly without any errors.
Remove these lines because they are for the Android SDK resource values, not your app.
import android.R;
import android.R.xml;
Then try to clean and rebuild.
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad