tsukanomon
tsukanomon

Reputation: 1270

Android Studio - Deploys my app without new changes

My problem is basically that Android Studio wont deploy my app with my changes in the new code. Heres my case scenario:

I have a wifi direct code working like this (just testing with its methods):

    public void peerDiscovery(){

    mWifiDirectManager.discoverPeers(mChannel,

      new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {
             Log.v(TAG,"Discovery Peers Success");


        }

        @Override
        public void onFailure(int reason) {
            Log.e(TAG,"Error on Discovery Peers, code: "+reason);


        }
     });
}

The above code works and then I decided to change it by adding the method: setPeerDiscoveryHandler(boolean isSuccess);

After the changes my code was as follows:

 public void peerDiscovery(){

    mWifiDirectManager.discoverPeers(mChannel,
      new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {
            setPeerDiscoveryHandler(true);
            Log.v(TAG, "Message Sent");
        }

        @Override
        public void onFailure(int reason) {
            Log.e(TAG,"Error on Discovery Peers, code: "+reason);
            setPeerDiscoveryHandler(false);
        }
    });
}

But guess what, even after doing this new code and clicking on the Run button, it was like I didnt do nothing! And I realized that was happening after I started to check my logcat and the message:

"Discovery Peers Success"

was being printed, but I had it removed from the code (as you can see in my new code). I tried to rebuild and clean the project, uninstall the application from the mobile before deploying it again, but nothing seems to take effect. Any thoughts about it ?

Thanks in advance for all help guyz.

Upvotes: 3

Views: 3748

Answers (4)

Mohit Rana
Mohit Rana

Reputation: 1

Force a Full Build on Each Run:

You can configure Android Studio to always perform a clean build before running: Go to Run > Edit Configurations. Select your app configuration and scroll down to Before Launch. Click on Add (+), then select Gradle-aware Make. This ensures that a Gradle build task runs before launching the app, forcing it to rebuild and apply any XML changes. It works 100%

Upvotes: 0

Himesh Perera
Himesh Perera

Reputation: 309

Just go to "File -> Settings -> Build, Execution, Deployement -> Deplyoyment ->" and just disable the automatic Perform Run when ApplyChanges fails.

Upvotes: 0

Tsvetomir Todorov
Tsvetomir Todorov

Reputation: 1

Android studio 4.2.x

This solved my problem:

In Android Studio, go to Run > Edit Configurations -> Disable "Allow parallel run"

Upvotes: 0

tsukanomon
tsukanomon

Reputation: 1270

Well guyz, turns out that I found the solution for that problem of mine. Actually, I dont know why, but when that starts to happen you need to click on a button called "Sync Project with Gradle Files", and it will sync all your project files all over again. Like I said before, I really dont understand why that is needed, but in case someone have this problem in the future thats a solution. Thanks.

Upvotes: 3

Related Questions