Flutter run出现No Provisioning Profile was found for your project‘s Bundle Identifier or your device

在Flutter开发中遇到Xcodebuild安装时找不到ProvisioningProfile的问题,通过执行flutterclean清理缓存,然后在Xcode中Product-CleanBuildFolder,最后运行flutterbuildbundle重新生成二进制文件,解决了无法通过flutterrun部署到设备上的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

出现场景

在Flutter中,使用flutter run运行debug模式, 等待xcode build完成后,在install时出现以下错误。

Launching lib/main.dart on iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: DD2AWWF43G
Running Xcode build...
Xcode build done.                                           85.0s
Installing and launching...
No Provisioning Profile was found for your project's Bundle Identifier or your 
device. You can create a new Provisioning Profile for your project in Xcode for 
your team by:
  1- Open the Flutter project's Xcode target with
       open ios/Runner.xcworkspace
  2- Select the 'Runner' project in the navigator then the 'Runner' target
     in the project settings
  3- In the 'General' tab, make sure a 'Development Team' is selected. 
     You may need to:
         - Log in with your Apple ID in Xcode first
         - Ensure you have a valid unique Bundle ID
         - Register your device with your Apple Developer Account
         - Let Xcode automatically provision a profile for your app
  4- Build or run your project again

It's also possible that a previously installed app with the same Bundle 
Identifier was signed with a different certificate.

For more information, please visit:
  https://flutter.io/setup/#deploy-to-ios-devices

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════
2020-01-09 10:18:45.163 ios-deploy[43201:5238881] [ !! ] Error 0xe8008015: A valid provisioning profile for this executable was not found. AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0)
Could not install build/ios/iphoneos/Runner.app on 2fd298b64f27b47f0917050a9f7ec70cdc98f033.
Try launching Xcode and selecting "Product > Run" to fix the problem:
 open ios/Runner.xcworkspace

解决方案

错误报的是证书不对。
按照提示,用xcode打开ios/Runner.xcworkspace,检查了签名设置都是正常的,使用xcode 直接run是能正常运行起来的,只是使用flutter run无法正常运行。所以应该是Flutter中有签名缓存,导致打包时使用的以前的签名。

  1. flutter clean
    在flutter项目目录中,使用flutter clean清理缓存.
  2. xcode clean build
    使用xcode打开ios目录,选择菜单栏中的Product->Clean Build Folder.
    在这里插入图片描述
    clean完成后,会出现以下提示
    在这里插入图片描述
  3. flutter build bundle
    最后在flutter项目目录下运行flutter build bundle,重新生成ios app的二进制文件。

再次运行flutter run, 就能正常运行了。

### 解决Gradle版本与Flutter使用的Java版本不兼容的方法 当遇到Gradle版本和Java版本不一致的问题时,可以采取多种措施来确保两者之间的兼容性。 #### 修改Gradle的JVM配置 为了使Gradle使用特定版本的JVM,在项目中的`gradle.properties`文件里指定所需的JVM路径。这可以通过设置环境变量`ORG_GRADLE_PROJECT_javaHome`指向所需安装目录下的Java Home实现[^2]: ```properties org.gradle.java.home=/path/to/your/jdk ``` 对于Windows操作系统而言,上述路径可能类似于 `C:\Program Files\Java\jdk-17`;而对于Linux或macOS,则可能是 `/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home`. #### 使用Flutter Doctor诊断工具 通过执行命令`flutter doctor -v`可以帮助识别当前环境中存在的任何潜在问题,并提供有关正在使用的具体Java版本的信息。这对于确认是否已经解决了之前的错误非常有用[^3]: ```bash flutter doctor -v ``` 此命令会显示详细的系统状态报告,包括已安装软件包及其对应版本号等信息。 #### 配置Android Studio内置JDK 由于Android Studio自带了一个版本的Java开发套件(JDK),默认情况下Flutter会选择它作为编译器。如果没有安装Android Studio的话,就需要依赖于由shell脚本定义好的`JAVA_HOME`环境变量所指明的那个版本。如果该变量未被设定过,那么程序将会尝试查找PATH中可用的第一个java可执行文件[^4]. 因此建议优先考虑利用IDE内部集成的支持功能而不是手动调整外部依赖关系,除非确实有必要这样做。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值