How to switch flutter project on Android studio 2021.2.1 from my windows machine to android studio ladybug on my mac through Git

时间: 2025-01-06 admin 业界

I am making an app I plan to release on iPhone and Android in this coming year. I have been trying to switch the code onto my new Mac and on Android Studio Ladybug, but no matter what I do, I cannot get the project to run without throwing errors on my m1 Mac. I would like it to be on my Mac so I can 'code on the go'. I have tried using Chatgpt to help fix errors, but it brings me in circles and never helps me fix anything.

The current issue I am facing is when I run 'flutter pub get' .... (OS Error: File name too long, errno = 63) Failed to update packages. but I can go through my ~ .zshrc file and there are no duplicates. Does anyone have any pointers! Thanks!

But when actually running the flutter application I get

FAILURE: Build failed with an exception.

  • What went wrong: Could not open cp_settings generic class cache for settings file '/Users/lucaskelbe/StudioProjects/MyFitPlan/android/settings.gradle' (/Users/lucaskelbe/.gradle/caches/7.5/scripts/cauwumxt3vajlc7mm71a6u491).

BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 65

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at

BUILD FAILED in 3s

I have tried making sure my gradle and java were compatible versions, as well as spending 8 hours total trying to fix the issues, but to no avail.

my ~ .zshrc file looks like this:

export JAVA_HOME=$(/usr/libexec/java_home -v 23)
export PATH=$JAVA_HOME/bin:$PATH

# Remove repeated entries
export PATH="$HOME/development/flutter/bin:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"

export FLUTTER_ROOT="$HOME/development/flutter"
export ANDROID_HOME=$HOME/Library/Android/sdk


export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"

export GEM_HOME=$HOME/.gem
export PATH="$GEM_HOME/bin:$PATH"
setopt hist_ignore_all_dups

My android/build.gradle looks like this:

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        // Android Gradle Plugin - Update to a compatible version
        classpath 'com.android.tools.build:gradle:8.1.2'
        // Google Services Plugin - Adjust to latest stable version
        classpath 'com.google.gms:google-services:4.3.15'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

// Set root project build directory
rootProject.buildDir = '../build'

// Configure subproject build directories
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

// Clean task
tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

And my android/settings.gradle looks like this:

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.10" apply false
    id "org.jetbrains.kotlin.android" version "1.7.10" apply false
    id 'com.google.gms.google-services' version '4.3.0' apply false
}

include ':app'