title: Explain Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins
body: <p>I will keep it simple. I am using both kotlin and java in my Android project. I can provide my gradle files if necessary.</p>
  <p>I need the following java plugins in my project: id 'java-library'
  id &quot;org.web3j&quot;. They work on an older version of Android gradle <code>('com.android.tools.build:gradle:3.6.3' ; distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip)</code> but not on the newest one <code>(&quot;com.android.tools.build:gradle:4.1.1&quot; ; distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip)</code> from which I need other functionality. When I try to add them I get the following error.</p>
  <pre><code>Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins
  </code></pre>
  <p>Old gradle version has plugins:</p>
  <pre><code>apply plugin: 'com.android.application'
  
  apply plugin: 'kotlin-android'
  apply plugin: 'com.google.gms.google-services'
  apply plugin: 'kotlin-android-extensions'
  </code></pre>
  <p>New gradle version has plugins:</p>
  <pre><code>plugins {
      id 'com.android.application'
      id 'kotlin-android'
      id  'com.google.gms.google-services'
     // id &quot;org.web3j&quot; version &quot;4.8.1&quot;
    // id 'java-library'
  }
  </code></pre>
  <p>I found others with the same problem but with no real answer. One workaround I found here is to configure them for a subproject or something, but I don't really understand how. Can somebody help? Ideally tell me what and where to put it in which gradle file and how it works (from my understanding I have only 1 project not many in my Android app).
  This is the code that I found:</p>
  <pre><code>configure(allprojects) {
    println &quot;applying java plugin to $project&quot;
    apply plugin: 'java-library'
  
    //...
  }
  </code></pre>