1

I have imported a project in android studio, after doing the build of the project, i am getting 100's of error in java classes with multiple package imports.

I have tried changing the package name in the AndroidManifest.xml file and change the applicationId in app level build.gradle files, but i couldn't resolve it

this is my manifest file where the package name is defined :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.space.demoapp">

     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission 
        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission 
        android:name="android.permission.READ_EXTERNAL_STORAGE" />

     <application android:name=".SpaceApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:testOnly="false">
    <activity 
        android:name=".accountDetails.BrandProductDetailActivity"
        android:exported="false"/>
    </application>

the app level build.gradle :

defaultConfig {
    applicationId "com.space.demoapp"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
    "android.support.test.runner.AndroidJUnitRunner"
}

and some classes where the package imports are different from what is defined in mnifest.xml and build.gradle :

package com.example.bchauhan.demoapp;

import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;

import com.space.demoapp.data.model.DatumPosts;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.example.bchauhan.demoapp.HomeFragment.FIRST_PAGE;
import static com.space.demoapp.MainActivity.FIRST_PAGE;

So in the project there are 2 packages : different package

I am expecting that while importing any class it should import

package com.space.demoapp

not package com.example.bchauhan.demoapp

Please help.

2 Answers2

0

It means required Packages are, not in your project. please remove all the import package header lines and give the correct package of the needed class otherwise resolve by (alt+enter)

0

i think you just renamed it. here I tell you the shortcut, just go to the Application, leftclick on it then click on Local History, and go on the time where you change the package name and then go to the package name and Refector it instead of renaming it.

Irfan Yaqub
  • 140
  • 10
  • the problem is i have not made any change in the package name, it's someone else's project which i am trying to build and play. the different package name appeared when i did a build on my own system and started checking the code. I did changed the applicationId in build file and build it , but the error was same in every class – Ankit Kumar Dec 24 '18 at 06:47
  • then you didn't import Correctly. please visit [link]:https://stackoverflow.com/a/35223130/10598286 – Irfan Yaqub Dec 26 '18 at 07:46